SlideShare a Scribd company logo
1 of 17
Coding Standards
(Drupal Best Practices)
Module Folder Structure and Files:
● Module name should which reflects our functionality
○ Prefer to use prefix as Site name. (Ex: missiontix_custom_price)
○ Extending features of any contrib module (Ex: missiontix_views_ext)
MY_MODULE
-- MY_MODULE.info
-- MY_MODULE.module
-- MY_MODULE.install
- js
-- MY_MODULE.js
- css
-- MY_MODULE.css
- src
-- EXT_LIBRARY.php
-- ...
● Files:
○ Each file ends with empty at end
Naming Conventional
1. Variables Name
a. String Variables
b. Number Variables
c. Array
d. Object
2. Function Name
3. Constant Name
4. Class Name
Control and Conditional Statements
● White Space between control statement and
opening parenthesis.
● Curly braces- Increases readability.
● Closing brace should be on new line.
● Space before and after the operator.
● No Space between Increment/Decrement
operators.
● Don't use "else if".
Looping Statements
Function Declaration and Definition
● Ensure your function return
some value.
● Include Description of the
function in command.
● Command contains the
Arguments details and return
type details.
● Specifying the implementing
HOOK details in function
descriptions.
Class and Object
● Class name should starts with
Capital.
● Try to use Namespace for class.
● Leave an empty line between end
of method and end of class
definition.
● Use “$this” as object to access the
same class Methods and variables.
INFO File
● Drupal uses “.info” files to
store metadata about
themes and modules.
● Optionally able to add
○ Files
○ Dependencies
○ Script
○ CSS
Module File
Install File
● hook_schema() take care of create and
deletion of tables.
● hook_update_N() will works on update.php
callback.
● Delete the variables(variable_del()) and other
table entries in hook_uninstall().
● External libraries related implementations are
done in hook_requirements().
● Install is similar in both Drupal 7 and Drupal 8.
INC Files
● .inc files used for Splitting module code into
files.
● .inc file is only loaded for the specific path.
● The function module_load_include('inc',
MODULE_NAME, MODULE_NAME.INCLUDE)
help to load INC files
Syntax: module_load_include('inc', MODULE_NAME,
MODULE_NAME.INCLUDE)
JS & CSS Files
● These JS and CSS files are only used for specific features.
● Including Files
○ In Info File
scripts[] = MODULE.js
stylesheets[all][] = MODULE.css
○ Added using function
■ drupal_add_js(PATH) ;
■ drupal_add_css(PATH) ;
Tools
● PAReview.sh online tool to review the code
○ https://pareview.sh/
○ https://www.drupal.org/project/pareviewsh
● PHP CodeSniffer
○ Drupa Coder module (https://www.drupal.org/project/coder)
phpcs --standard=Drupal /var/www/html/annotation_store/annotation_store.info.yml
phpcs --standard=Drupal /var/www/html/annotation_store
Do and Don’t
● Don’t write your PHP code inside Block , Views, Panels,. Instead of write in
your module and call the function.
● Usage of “function_exists()”.
● Use isset() and empty().
● Function module_load_include().
● variable_get(), variable_set() and variable_del().
● In alters don’t unset() reference variables just hide().
● Custom Query parameter instead of URL parameter.
Cond,.
● Use LANGUAGE_NONE instead of und.
● Power of “entity_metadata_wrapper()”
$entityObj = entity_metadata_wrapper(ENTITY_TYPE, ENTITY_ID);
// Print values
$value_1 = $entityObj->FIELD_NAME_1->value();
print_r($value_1);
$value_2 = $entityObj->FIELD_NAME_2->value();
print_r($value_1);
//Update values
$entityObj->FIELD_NAME_1->set(UPDATE_VALUE_1);
$entityObj->FIELD_NAME_2->set(UPDATE_VALUE_2);
Cond,.
Hacking contrib Module
● Applying Patches
● Adding our custom hacks.
● Create your “Custom Hook Alter” for changing values.
○ Drupal 7: drupal_alter('MYMODULE_FUNCTION_NAME', $param1, $param2);
○ Drupal 8: Drupal::moduleHandler()->alter('MYMODULE_FUNCTION_NAME', $param1, $param2);
function MYMODULE_FUNCTION_NAME_alter(&$param1, &$param2) {
--------
--------
}
Thanks All

More Related Content

Similar to Drupal Coding Standards - do and don't

Presentation Dolibarr - information for developers and partners - devcamp Nan...
Presentation Dolibarr - information for developers and partners - devcamp Nan...Presentation Dolibarr - information for developers and partners - devcamp Nan...
Presentation Dolibarr - information for developers and partners - devcamp Nan...Laurent Destailleur
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module developmentRachit Gupta
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)sroo galal
 
Django course summary
Django course summaryDjango course summary
Django course summaryUdi Bauman
 
OpenCms Days 2014 - Responsive bootstrap templates reloaded
OpenCms Days 2014 - Responsive bootstrap templates reloadedOpenCms Days 2014 - Responsive bootstrap templates reloaded
OpenCms Days 2014 - Responsive bootstrap templates reloadedAlkacon Software GmbH & Co. KG
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master BuilderPhilip Norton
 
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Movel
 
Modules 101
Modules 101Modules 101
Modules 101gjcross
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS DrupalMumbai
 
Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Stephen Colebourne
 
Moodle Development Best Pracitces
Moodle Development Best PracitcesMoodle Development Best Pracitces
Moodle Development Best PracitcesJustin Filip
 
Balisage - EXPath Packaging
Balisage - EXPath PackagingBalisage - EXPath Packaging
Balisage - EXPath PackagingFlorent Georges
 
Doctrine Project
Doctrine ProjectDoctrine Project
Doctrine ProjectDaniel Lima
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionStephen Colebourne
 
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...Michael Rys
 
Kolla project onboarding - OpenStack Summit Berlin 2018
Kolla project onboarding - OpenStack Summit Berlin 2018Kolla project onboarding - OpenStack Summit Berlin 2018
Kolla project onboarding - OpenStack Summit Berlin 2018Eduardo Gonzalez Gutierrez
 
Keep your repo clean
Keep your repo cleanKeep your repo clean
Keep your repo cleanHector Canto
 

Similar to Drupal Coding Standards - do and don't (20)

Presentation Dolibarr - information for developers and partners - devcamp Nan...
Presentation Dolibarr - information for developers and partners - devcamp Nan...Presentation Dolibarr - information for developers and partners - devcamp Nan...
Presentation Dolibarr - information for developers and partners - devcamp Nan...
 
Drupal module development
Drupal module developmentDrupal module development
Drupal module development
 
Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)Odoo (Build module, Security, ORM)
Odoo (Build module, Security, ORM)
 
Django course summary
Django course summaryDjango course summary
Django course summary
 
OpenCms Days 2014 - Responsive bootstrap templates reloaded
OpenCms Days 2014 - Responsive bootstrap templates reloadedOpenCms Days 2014 - Responsive bootstrap templates reloaded
OpenCms Days 2014 - Responsive bootstrap templates reloaded
 
Becoming A Drupal Master Builder
Becoming A Drupal Master BuilderBecoming A Drupal Master Builder
Becoming A Drupal Master Builder
 
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
Scaling AngularJS: Enterprise SOA on the MEAN Stack (Responsive Web & Mobile)
 
Modules 101
Modules 101Modules 101
Modules 101
 
13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS 13th Sep, Drupal 7 advanced training by TCS
13th Sep, Drupal 7 advanced training by TCS
 
Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)Java SE 9 modules - an introduction (July 2018)
Java SE 9 modules - an introduction (July 2018)
 
Migrating data to Drupal 8
Migrating data to Drupal 8Migrating data to Drupal 8
Migrating data to Drupal 8
 
Moodle Development Best Pracitces
Moodle Development Best PracitcesMoodle Development Best Pracitces
Moodle Development Best Pracitces
 
Balisage - EXPath Packaging
Balisage - EXPath PackagingBalisage - EXPath Packaging
Balisage - EXPath Packaging
 
Doctrine Project
Doctrine ProjectDoctrine Project
Doctrine Project
 
Why Drupal is Rockstar?
Why Drupal is Rockstar?Why Drupal is Rockstar?
Why Drupal is Rockstar?
 
Drupal
DrupalDrupal
Drupal
 
Java SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introductionJava SE 9 modules (JPMS) - an introduction
Java SE 9 modules (JPMS) - an introduction
 
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
U-SQL Killer Scenarios: Taming the Data Science Monster with U-SQL and Big Co...
 
Kolla project onboarding - OpenStack Summit Berlin 2018
Kolla project onboarding - OpenStack Summit Berlin 2018Kolla project onboarding - OpenStack Summit Berlin 2018
Kolla project onboarding - OpenStack Summit Berlin 2018
 
Keep your repo clean
Keep your repo cleanKeep your repo clean
Keep your repo clean
 

More from Arunkumar Kupppuswamy

More from Arunkumar Kupppuswamy (6)

Drupal Development Tools.pdf
Drupal Development Tools.pdfDrupal Development Tools.pdf
Drupal Development Tools.pdf
 
Build website using Open Source Technology
Build website using Open Source TechnologyBuild website using Open Source Technology
Build website using Open Source Technology
 
Drupal 8 Performance & SEO optimizaion
Drupal 8 Performance & SEO optimizaionDrupal 8 Performance & SEO optimizaion
Drupal 8 Performance & SEO optimizaion
 
D8 search api
D8   search apiD8   search api
D8 search api
 
Object Oriented Programming - Basic Concepts
Object Oriented Programming - Basic ConceptsObject Oriented Programming - Basic Concepts
Object Oriented Programming - Basic Concepts
 
Drupal 8 : Introduction to Big Pipe
Drupal 8 : Introduction to Big PipeDrupal 8 : Introduction to Big Pipe
Drupal 8 : Introduction to Big Pipe
 

Recently uploaded

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Drupal Coding Standards - do and don't

  • 2. Module Folder Structure and Files: ● Module name should which reflects our functionality ○ Prefer to use prefix as Site name. (Ex: missiontix_custom_price) ○ Extending features of any contrib module (Ex: missiontix_views_ext) MY_MODULE -- MY_MODULE.info -- MY_MODULE.module -- MY_MODULE.install - js -- MY_MODULE.js - css -- MY_MODULE.css - src -- EXT_LIBRARY.php -- ... ● Files: ○ Each file ends with empty at end
  • 3. Naming Conventional 1. Variables Name a. String Variables b. Number Variables c. Array d. Object 2. Function Name 3. Constant Name 4. Class Name
  • 4. Control and Conditional Statements ● White Space between control statement and opening parenthesis. ● Curly braces- Increases readability. ● Closing brace should be on new line. ● Space before and after the operator. ● No Space between Increment/Decrement operators. ● Don't use "else if".
  • 6. Function Declaration and Definition ● Ensure your function return some value. ● Include Description of the function in command. ● Command contains the Arguments details and return type details. ● Specifying the implementing HOOK details in function descriptions.
  • 7. Class and Object ● Class name should starts with Capital. ● Try to use Namespace for class. ● Leave an empty line between end of method and end of class definition. ● Use “$this” as object to access the same class Methods and variables.
  • 8. INFO File ● Drupal uses “.info” files to store metadata about themes and modules. ● Optionally able to add ○ Files ○ Dependencies ○ Script ○ CSS
  • 10. Install File ● hook_schema() take care of create and deletion of tables. ● hook_update_N() will works on update.php callback. ● Delete the variables(variable_del()) and other table entries in hook_uninstall(). ● External libraries related implementations are done in hook_requirements(). ● Install is similar in both Drupal 7 and Drupal 8.
  • 11. INC Files ● .inc files used for Splitting module code into files. ● .inc file is only loaded for the specific path. ● The function module_load_include('inc', MODULE_NAME, MODULE_NAME.INCLUDE) help to load INC files Syntax: module_load_include('inc', MODULE_NAME, MODULE_NAME.INCLUDE)
  • 12. JS & CSS Files ● These JS and CSS files are only used for specific features. ● Including Files ○ In Info File scripts[] = MODULE.js stylesheets[all][] = MODULE.css ○ Added using function ■ drupal_add_js(PATH) ; ■ drupal_add_css(PATH) ;
  • 13. Tools ● PAReview.sh online tool to review the code ○ https://pareview.sh/ ○ https://www.drupal.org/project/pareviewsh ● PHP CodeSniffer ○ Drupa Coder module (https://www.drupal.org/project/coder) phpcs --standard=Drupal /var/www/html/annotation_store/annotation_store.info.yml phpcs --standard=Drupal /var/www/html/annotation_store
  • 14. Do and Don’t ● Don’t write your PHP code inside Block , Views, Panels,. Instead of write in your module and call the function. ● Usage of “function_exists()”. ● Use isset() and empty(). ● Function module_load_include(). ● variable_get(), variable_set() and variable_del(). ● In alters don’t unset() reference variables just hide(). ● Custom Query parameter instead of URL parameter.
  • 15. Cond,. ● Use LANGUAGE_NONE instead of und. ● Power of “entity_metadata_wrapper()” $entityObj = entity_metadata_wrapper(ENTITY_TYPE, ENTITY_ID); // Print values $value_1 = $entityObj->FIELD_NAME_1->value(); print_r($value_1); $value_2 = $entityObj->FIELD_NAME_2->value(); print_r($value_1); //Update values $entityObj->FIELD_NAME_1->set(UPDATE_VALUE_1); $entityObj->FIELD_NAME_2->set(UPDATE_VALUE_2);
  • 16. Cond,. Hacking contrib Module ● Applying Patches ● Adding our custom hacks. ● Create your “Custom Hook Alter” for changing values. ○ Drupal 7: drupal_alter('MYMODULE_FUNCTION_NAME', $param1, $param2); ○ Drupal 8: Drupal::moduleHandler()->alter('MYMODULE_FUNCTION_NAME', $param1, $param2); function MYMODULE_FUNCTION_NAME_alter(&$param1, &$param2) { -------- -------- }