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

Code

By editor , 10 February, 2017

Render a Render array to HTML code.

Tags

  • Drupal 8
  • Code
  • Module

Example :

$result =  array(
  '#markup' => 'Hello. This is my First Page',
);
$renderer = \Drupal::service('renderer');
$html = $renderer->render($result);

 

By editor , 10 February, 2017

Insert a view on a custom page or block

Tags

  • Drupal 8
  • Code
  • Views

This tutorial show toy how to insert an existing views into a custom page or custom block.

 

By editor , 10 February, 2017

Load entity dynamicly by entity type on Drupal 8

Tags

  • Drupal 8
  • Code
  • Entity

Using entity_load function.

Example:
$entity = entity_load($entity_type, $id);

Using Entity Manager

Example:
$entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($id);

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 , 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

Pagination

  • Previous page
  • 7
  • Next page
Code

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