Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Drupal 8

By editor , 31 January, 2017

Change the states of an element based on another element (field)

Tags

  • Drupal 8
  • Code
  • Field

Note : The tutorial is usins States VISIBLE, but can also use for other html parameters such as : REQUIRED, EXPENDED, CHECKED ...

The selector is an "JQUERY_SELECTOR"

By editor , 18 January, 2017

Use multiple databases on drupal 8

Tags

  • Drupal 8
  • Code
  • Database

Move some tables into another database.

Example:

By editor , 18 January, 2017

Create an advances Search system for Drupal 8 with Search API.

Tags

  • Drupal 8
  • Search
  • Module

Search API and Database Search server.

1. Uninstall drupal basic Search
2. Install search_api and search_api_db
  NOTE : You can also use another database configures on settings.php
3. Add a Search Server (/admin/config/search/search-api/add-server).

By editor , 13 January, 2017

Create a field in a node entity programmatically on Drupal 8.

Tags

  • Drupal 8
  • Code
  • Field

Example.
Step 1 : Create field storage.
\Drupal\field\Entity\FieldStorageConfig::create(array(
  'field_name' => 'field_text',
  'entity_type' => 'node',
  'type' => 'text',
  'cardinality' => -1,

By editor , 12 January, 2017

CSS Styling tips for Print

Tags

  • Drupal 8
  • Code

Add CSS for Print

Method 1 : Add a specific styling sheet for Print.

On your theme (THEME.info.yml for D8 and THEME.info for D7), Add css file as [print].
Example
stylesheets[print][] = css/print.css

 

By editor , 11 January, 2017

Make Some operations Programmatically - Hook Update Deploy Tools

Tags

  • Drupal 8
  • Code
  • Drupal 7
  • Module

Hook Update Deploy Tools is a great contrib module help to make most of site deploy operations programmatically.
Link : https://www.drupal.org/project/hook_update_deploy_tools

By editor , 10 January, 2017

Get Entity data and metadata

Tags

  • Drupal 8
  • Code
  • Entity

Get entity types list :

$itmes_list= \Drupal::entityTypeManager()->getDefinitions();

Get Entity type (Content / Config)

$itmes_list['node']->getGroup();
$itmes_list['node_type']->getGroup();

By editor , 3 January, 2017

Manage custom package using composer.

Tags

  • Drupal 8
  • Code
  • Composer

Composer can hadle CVS (git, svn ...) and ZIP packages.
To install/Update your custom modules, add a custom repository to the composer.json file, following this example.

1. Add package repositories
Here, youtubeapi and sadb

By editor , 3 January, 2017

Create a Drupal 9 Project using composer.

Tags

  • Drupal 8
  • Code
  • Composer

Using recommended-project template

 

composer create-project drupal/recommended-project my-project

For more information, see : https://www.drupal.org/docs/develop/using-composer/starting-a-site-using-drupal-composer-project-templates

 

By editor , 20 December, 2016

Drupal 8 Url Tips. Get Name, Path, Args ...

Tags

  • Drupal 8
  • Code

Drupal 8 Url Object
use Drupal\Core\Url;

Create a Url

Create Url from route name

$url = Url::fromRoute('<current>');
$url = Url::fromRoute('entity.node.canonical', ['node' => 1], []);

Pagination

  • Previous page
  • 8
  • Next page
Drupal 8

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer