Skip to main content

Posts

Showing posts from July, 2019

Theme table with pager - Drupal 8

public function nodeList() {     $header = [       'Nid',       'Title',     ];     $query = \Drupal::database()->select('node', 'n');     $query->fields('n', ['nid']);     $pager = $query->extend('Drupal\Core\Database\Query\PagerSelectExtender')->limit(10);     $results = $pager->execute()->fetchAll();     foreach ($results as $key => $result) {       $node = Node::load($result->nid);       $row = [];       $row = [         'nid' => $node->id(),         'title' => $node->getTitle(),       ];       $rows[] = $row;     }     $build['table_data'] = [       '#type' => 'table',       '#header' => $header,       '#rows' => $rows,     ];     // Finally add the pager.     $build['pager'] = array(       '#type' => 'pager'     );     return $build;   }

Docksal usage with Drupal

DOCKSAL ======= 1. Drupal installation using composer ref: https://blog.docksal.io/creating-drupal-8-project-from-scratch-using-pre-installed-composer-in-docksal-cli-bfe49b0042e2 # Create new directory for the project mkdir my-new-project # Go to my new dir cd my-new-project # Download Drupal 8 using composer repo recommended in Drupal docs fin run-cli composer create-project drupal-composer/drupal-project:8.x-dev . --stability dev --no-interaction # Initialize Docksal project root mkdir .docksal # Configure DOCROOT to match checked out files fin config set DOCROOT=web # Start my project containers fin project start 2. To start existing project on Docksal   fin project start / fin up 3. DB settings (default)    db name: default    username: user    password: user    host: db 4. Install PHPMyAdmin to project   fin addon install pma   # Then access it like http://pma.project-name.docksal   # To install any addon (ref https://docs.docksal.io/fin/addons

Deploy Magento 2 application to another server

Take the database backup. Import the database to the new server. Change base URL in the imported database. In table core_config_data In Path column: web/unsecure/base_url, web/secure/base_url Run the following commands:  bin/magento setup:di:compile bin/magento setup:static-content:deploy -f bin/magento cache:flush sudo chmod -R 777 var/