{"id":856,"date":"2015-10-02T22:00:26","date_gmt":"2015-10-02T22:00:26","guid":{"rendered":"https:\/\/www.codexworld.com\/?p=856"},"modified":"2016-04-22T16:56:01","modified_gmt":"2016-04-22T16:56:01","slug":"drupal-custom-module-development-tutorial","status":"publish","type":"post","link":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/","title":{"rendered":"Drupal custom module development tutorial"},"content":{"rendered":"<p>The module helps to extend and customize Drupal functionality. Drupal have three kinds of modules, core, contributed and custom. In this tutorial, you can learn how to create your own module in Drupal 7. Our step by step guide helps beginners to make a drupal 7 module from scratch. If you are new to Drupal, you can read <a href=\"http:\/\/www.codexworld.com\/drupal-7-installation-setup-tutorial-beginners\/\">Drupal 7 installation and setup tutorial for beginners<\/a> first.<br \/>\nLet&#8217;s start the creation of your own Drupal module.<\/p>\n<h2>Step 1) Creating module folder and files<\/h2>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Choose a short name for your module.  Module name must start with a letter, and it must contain only lower-case letters and underscores. For this example, we&#8217;ll choose &#8220;latest_posts&#8221; as module name.<\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Create a folder with module name (latest_posts) in <code>sites\/all\/modules\/<\/code> directory.<\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Create a <code>latest_posts.info<\/code> file in the module directory (<code>sites\/all\/modules\/latest_posts\/<\/code>) for telling drupal about your module. <code>latest_posts.info<\/code> file contains the meta information of your module and it is required for your module. Missing of this file your module will not appear in the module listing.<\/p>\n<p><code>sites\/all\/modules\/latest_posts\/latest_posts.info<\/code> file contains the following code:<\/p>\n<pre>\r\nname = Latest Posts\r\ndescription = A block module that lists links to newly created posts developed by CodexWorld.\r\ncore = 7.x\r\n<\/pre>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Create a module file (<code>latest_posts.module<\/code>) into the module directory (<code>sites\/all\/modules\/latest_posts\/<\/code>). <\/p>\n<ul>\n<li><span class=\"glyphicon glyphicon glyphicon-ok\"><\/span>&nbsp;Module file has a name of the module directory name and an extension of .module.<\/li>\n<li><span class=\"glyphicon glyphicon glyphicon-ok\"><\/span>&nbsp;Module file is a PHP file and begins with opening PHP tag.<\/li>\n<li><span class=\"glyphicon glyphicon glyphicon-ok\"><\/span>&nbsp;Omit the closing (?>) tag for avoiding the runtime issues on the certain server.<\/li>\n<\/ul>\n<p>For now <code>sites\/all\/modules\/latest_posts\/latest_posts.module<\/code> file contains the following code:<\/p>\n<pre><span style=\"color: #0000BB\">&lt;?php<\/pre>\n<p><b>TEST<\/b><br \/>\n<span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Go to <b>Modules<\/b> listing page and scroll down of the list, you&#8217;ll see the <b>Latest Posts<\/b> module under the <b>OTHER<\/b> category.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/latest-post-drupal-custom-module-in-list-by-codexworld.png\" alt=\"latest-post-drupal-custom-module-in-list-by-codexworld\" width=\"684\" height=\"132\" class=\"alignnone size-full wp-image-857\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/latest-post-drupal-custom-module-in-list-by-codexworld.png 684w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/latest-post-drupal-custom-module-in-list-by-codexworld-300x58.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/latest-post-drupal-custom-module-in-list-by-codexworld-200x39.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/latest-post-drupal-custom-module-in-list-by-codexworld-346x67.png 346w\" sizes=\"auto, (max-width: 684px) 100vw, 684px\" \/><\/div>\n<h2>Step 2) Declaring the help hook<\/h2>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Implement some hooks in <code>latest_posts.module<\/code> file. Also, it is a very good idea to document about how your module works in comments.<\/p>\n<pre><span style=\"color: #FF8000\">\/**<br \/>&nbsp;*&nbsp;@file<br \/>&nbsp;*&nbsp;A&nbsp;block&nbsp;module&nbsp;that&nbsp;displays&nbsp;latest&nbsp;posts.<br \/>&nbsp;*\/<\/span><\/pre>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Implement a help hook (hook_help). This hook provides help and additional information about your module. Create a function called <code>latest_posts_help()<\/code> in <code>latest_posts.module<\/code> file and place the following code.<\/p>\n<pre><span style=\"color: #FF8000\">\/**<br \/>&nbsp;*&nbsp;Implements&nbsp;hook_help().<br \/>&nbsp;*<br \/>&nbsp;*&nbsp;Displays&nbsp;help&nbsp;and&nbsp;module&nbsp;information.\r\n<br \/>&nbsp;*\/<br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">latest_posts_help<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$path<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$arg<\/span><span style=\"color: #007700\">)&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;switch&nbsp;(<\/span><span style=\"color: #0000BB\">$path<\/span><span style=\"color: #007700\">)&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;<\/span><span style=\"color: #DD0000\">\"admin\/help#latest_posts\"<\/span><span style=\"color: #007700\">:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;p&gt;'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">t<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">\"Displays&nbsp;links&nbsp;to&nbsp;newly&nbsp;created&nbsp;posts&nbsp;developed&nbsp;by&nbsp;CodexWorld\"<\/span><span style=\"color: #007700\">)&nbsp;.&nbsp;<\/span><span style=\"color: #DD0000\">'&lt;\/p&gt;'<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>}<\/span><\/pre>\n<p><b>TEST<\/b><br \/>\n<span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Go to the <b>Modules<\/b> listing page <b>=><\/b> Check the checkbox to enable your module <b>=><\/b> Click on <b>Save configuration<\/b>.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/enable-drupal-custom-module-in-list-by-codexworld.png\" alt=\"enable-drupal-custom-module-in-list-by-codexworld\" width=\"610\" height=\"181\" class=\"alignnone size-full wp-image-858\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/enable-drupal-custom-module-in-list-by-codexworld.png 610w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/enable-drupal-custom-module-in-list-by-codexworld-300x89.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/enable-drupal-custom-module-in-list-by-codexworld-200x59.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/enable-drupal-custom-module-in-list-by-codexworld-346x103.png 346w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/div>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;<b>Help<\/b> link would appear with your module. <b>Help<\/b> link will redirect you to the module help page.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-help-link-by-codexworld.png\" alt=\"drupal-custom-module-help-link-by-codexworld\" width=\"258\" height=\"104\" class=\"alignnone size-full wp-image-859\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-help-link-by-codexworld.png 258w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-help-link-by-codexworld-200x81.png 200w\" sizes=\"auto, (max-width: 258px) 100vw, 258px\" \/><\/div>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Return to the <b>Modules<\/b> listing page <b>=><\/b> Uncheck the checkbox to disable your module <b>=><\/b> Click on <b>Save configuration<\/b>.<\/p>\n<h2>Step 3) Declaring the block<\/h2>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;<code>hook_block_info()<\/code> is used to define a block. Create <code>latest_posts_block_info()<\/code> function in <code>latest_posts.module<\/code> file and place the following code.<\/p>\n<pre><span style=\"color: #FF8000\">\/**<br \/>&nbsp;*&nbsp;Implements&nbsp;hook_block_info().<br \/>&nbsp;*\/<br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">latest_posts_block_info<\/span><span style=\"color: #007700\">()&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$blocks<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'latest_posts'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;The&nbsp;name&nbsp;that&nbsp;will&nbsp;appear&nbsp;in&nbsp;the&nbsp;block&nbsp;list.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'info'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">t<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Latest&nbsp;posts'<\/span><span style=\"color: #007700\">),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Default&nbsp;setting.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'cache'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">DRUPAL_CACHE_PER_ROLE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$blocks<\/span><span style=\"color: #007700\">;<br \/>}<\/span><\/pre>\n<p><b>TEST<\/b><br \/>\n<span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Go to the <b>Modules<\/b> listing page <b>=><\/b> Check the checkbox to enable your module <b>=><\/b> Click on <b>Save configuration<\/b>.<\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Navigate to the <b>Structure&nbsp;&raquo;&nbsp;Blocks<\/b>, scroll down to the bottom of the list. You&#8217;ll see your &#8220;Latest posts&#8221; block under the <b>Disabled<\/b> section.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-by-codexworld.png\" alt=\"drupal-custom-module-block-by-codexworld\" width=\"388\" height=\"80\" class=\"alignnone size-full wp-image-860\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-by-codexworld.png 388w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-by-codexworld-300x62.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-by-codexworld-200x41.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-by-codexworld-346x71.png 346w\" sizes=\"auto, (max-width: 388px) 100vw, 388px\" \/><\/div>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Return to the <b>Modules<\/b> listing page <b>=><\/b> Uncheck the checkbox to disable your module <b>=><\/b> Click on <b>Save configuration<\/b>.<\/p>\n<h2>Step 4) Retrieving data<\/h2>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Now we&#8217;ll create a custom function to retrieve the newly created posts from the database. <code>recent_posts_contents()<\/code> function retrieved the post which are created within last week. <code>recent_posts_contents()<\/code> function would be the following.<\/p>\n<pre><span style=\"color: #FF8000\">\/**<br \/>&nbsp;*&nbsp;Custom&nbsp;content&nbsp;function.&nbsp;<br \/>&nbsp;*&nbsp;<br \/>&nbsp;*&nbsp;Set&nbsp;beginning&nbsp;and&nbsp;end&nbsp;dates,&nbsp;retrieve&nbsp;the&nbsp;recent&nbsp;posts&nbsp;from&nbsp;the&nbsp;database<br \/>&nbsp;*\/<br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">recent_posts_contents<\/span><span style=\"color: #007700\">(){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Get&nbsp;today's&nbsp;date.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$today&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">getdate<\/span><span style=\"color: #007700\">();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Calculate&nbsp;the&nbsp;date&nbsp;a&nbsp;week&nbsp;ago.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$start_time&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">mktime<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">$today<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'mon'<\/span><span style=\"color: #007700\">],(<\/span><span style=\"color: #0000BB\">$today<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'mday'<\/span><span style=\"color: #007700\">]&nbsp;-&nbsp;<\/span><span style=\"color: #0000BB\">7<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #0000BB\">$today<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'year'<\/span><span style=\"color: #007700\">]);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Get&nbsp;all&nbsp;posts&nbsp;from&nbsp;one&nbsp;week&nbsp;ago&nbsp;to&nbsp;the&nbsp;present.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$end_time&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">time<\/span><span style=\"color: #007700\">();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Use&nbsp;Database&nbsp;API&nbsp;to&nbsp;retrieve&nbsp;recent&nbsp;posts.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$query&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">db_select<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'node'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'n'<\/span><span style=\"color: #007700\">)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;<\/span><span style=\"color: #0000BB\">fields<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'n'<\/span><span style=\"color: #007700\">,&nbsp;array(<\/span><span style=\"color: #DD0000\">'nid'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'title'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'created'<\/span><span style=\"color: #007700\">))<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;<\/span><span style=\"color: #0000BB\">condition<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">)&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Published.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">condition<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'created'<\/span><span style=\"color: #007700\">,&nbsp;array(<\/span><span style=\"color: #0000BB\">$start_time<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$end_time<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #DD0000\">'BETWEEN'<\/span><span style=\"color: #007700\">)\r\n<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;<\/span><span style=\"color: #0000BB\">orderBy<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'created'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'DESC'<\/span><span style=\"color: #007700\">)&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Most&nbsp;recent&nbsp;first.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">();\r\n<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$query<\/span><span style=\"color: #007700\">;&nbsp;&nbsp;<br \/>}<\/span><\/pre>\n<h2>Step 5) Generating block content<\/h2>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Using <code>hook_block_view<\/code> we&#8217;ll take the data generated by custom function (<code>recent_posts_contents()<\/code>) and turn into the block content. <code>recent_posts_block_view()<\/code> would be the following.<\/p>\n<pre><span style=\"color: #FF8000\">\/**<br \/>&nbsp;*&nbsp;Implements&nbsp;hook_block_view().<br \/>&nbsp;*&nbsp;<br \/>&nbsp;*&nbsp;Prepares&nbsp;the&nbsp;contents&nbsp;of&nbsp;the&nbsp;block.<br \/>&nbsp;*\/<br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">latest_posts_block_view<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$delta&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #DD0000\">''<\/span><span style=\"color: #007700\">)&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;switch&nbsp;(<\/span><span style=\"color: #0000BB\">$delta<\/span><span style=\"color: #007700\">)&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;<\/span><span style=\"color: #DD0000\">'latest_posts'<\/span><span style=\"color: #007700\">:<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$block<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'subject'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">t<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Latest&nbsp;posts'<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(<\/span><span style=\"color: #0000BB\">user_access<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'access&nbsp;content'<\/span><span style=\"color: #007700\">))&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Use&nbsp;our&nbsp;custom&nbsp;function&nbsp;to&nbsp;retrieve&nbsp;data.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">recent_posts_contents<\/span><span style=\"color: #007700\">();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Array&nbsp;to&nbsp;contain&nbsp;items&nbsp;for&nbsp;the&nbsp;block&nbsp;to&nbsp;render.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$items&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Iterate&nbsp;over&nbsp;the&nbsp;resultset&nbsp;and&nbsp;format&nbsp;as&nbsp;links.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">foreach&nbsp;(<\/span><span style=\"color: #0000BB\">$result&nbsp;<\/span><span style=\"color: #007700\">as&nbsp;<\/span><span style=\"color: #0000BB\">$node<\/span><span style=\"color: #007700\">)&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$items<\/span><span style=\"color: #007700\">[]&nbsp;=&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'data'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">l<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$node<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">title<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'node\/'&nbsp;<\/span><span style=\"color: #007700\">.&nbsp;<\/span><span style=\"color: #0000BB\">$node<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">nid<\/span><span style=\"color: #007700\">),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;No&nbsp;content&nbsp;in&nbsp;the&nbsp;last&nbsp;week.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">if&nbsp;(empty(<\/span><span style=\"color: #0000BB\">$items<\/span><span style=\"color: #007700\">))&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$block<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'content'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">t<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'No&nbsp;posts&nbsp;available.'<\/span><span style=\"color: #007700\">);&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/&nbsp;Pass&nbsp;data&nbsp;through&nbsp;theme&nbsp;function.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$block<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'content'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;<\/span><span style=\"color: #0000BB\">theme<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'item_list'<\/span><span style=\"color: #007700\">,&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'items'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">$items<\/span><span style=\"color: #007700\">));<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$block<\/span><span style=\"color: #007700\">;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>}<\/span><\/pre>\n<p><b>TEST<\/b><\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Go to the <b>Modules<\/b> listing page <b>=><\/b> Check the checkbox to enable your module <b>=><\/b> Click on <b>Save configuration<\/b>.<\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Navigate to the <b>Structure&nbsp;&raquo;&nbsp;Blocks<\/b> and scroll down to the bottom of the list. From <b>Disabled<\/b> section set your &#8220;Latest posts&#8221; block location to the page region and click on <b>Save blocks<\/b>.<\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;If you choose the &#8220;Sidebar first&#8221; region for &#8220;Latest posts&#8221; block, you&#8217;ll see the latest posts list at the left sidebar.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-view-by-codexworld.png\" alt=\"drupal-custom-module-block-view-by-codexworld\" width=\"295\" height=\"244\" class=\"alignnone size-full wp-image-862\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-view-by-codexworld.png 295w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-view-by-codexworld-200x165.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-block-view-by-codexworld-278x230.png 278w\" sizes=\"auto, (max-width: 295px) 100vw, 295px\" \/><\/div>\n<p><span class=\"glyphicon glyphicon-saved end-icon\"><\/span>&nbsp;Congratulation! You have successfully created the basic Drupal custom module.<\/p>\n<h2>Advanced feature:<\/h2>\n<p>Now we&#8217;ll implement some advanced feature and make the custom module more flexible. We&#8217;ll create a configuration form where admin would be able to adjust the number of links to display.<\/p>\n<h2>Step 6) Preparing for a module configuration form<\/h2>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;<code>Using hook_menu()<\/code>, we&#8217;ll define our form. Define <code>latest_posts_menu()<\/code> function in <code>latest_posts.module<\/code> file and add the following code.<\/p>\n<pre><span style=\"color: #FF8000\">\/**<br \/>&nbsp;*&nbsp;Implements&nbsp;hook_menu().<br \/>&nbsp;*\/<br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">latest_posts_menu<\/span><span style=\"color: #007700\">()&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$items&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;array();<br \/>&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$items<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'admin\/config\/content\/latest_posts'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'title'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Latest&nbsp;posts'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'Configuration&nbsp;for&nbsp;Latest&nbsp;posts&nbsp;module'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'page&nbsp;callback'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'drupal_get_form'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'page&nbsp;arguments'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<\/span><span style=\"color: #DD0000\">'latest_posts_form'<\/span><span style=\"color: #007700\">),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'access&nbsp;arguments'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;array(<\/span><span style=\"color: #DD0000\">'access&nbsp;administration&nbsp;pages'<\/span><span style=\"color: #007700\">),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">MENU_NORMAL_ITEM<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;);<br \/>&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$items<\/span><span style=\"color: #007700\">;<br \/>}<\/span><\/pre>\n<p><b>title<\/b>: Required. The title of the menu item.<br \/>\n<b>description<\/b>: The description of the menu item.<br \/>\n<b>page callback<\/b>: The function to call to display a web page when the user visits the path.<br \/>\n<b>page arguments<\/b>: An array of arguments to pass to the page callback function.<br \/>\n<b>access arguments<\/b>: An array of arguments to pass to the access callback function.<br \/>\n<b>type<\/b>: Types constant are MENU_NORMAL_ITEM, MENU_CALLBACK, MENU_SUGGESTED_ITEM, MENU_LOCAL_ACTION, MENU_LOCAL_TASK, MENU_DEFAULT_LOCAL_TASK.<\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Add the configuration button in Modules list by adding the following line in <code>latest_posts.info<\/code> file.<\/p>\n<pre>\r\n; NEW LINE\t\r\nconfigure = admin\/config\/content\/latest_posts\r\n<\/pre>\n<h2>Step 7) Declaring the form<\/h2>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;As per the &#8220;page callback&#8221;, <code>drupal_get_form<\/code> is called when the link is requested and &#8220;page arguments&#8221; values are passed to that function. By assigning <code>latest_posts_form<\/code>, we define that as both the form ID and the name of the function that will create our configuration form.<br \/>\nCreate a function called <code>latest_posts_form()<\/code> and build a form by adding elements to <code>$form<\/code> array. Add the following code to <code>latest_posts.module<\/code> file.<\/p>\n<pre><span style=\"color: #FF8000\">\/**<br \/>&nbsp;*&nbsp;Page&nbsp;callback:&nbsp;Latest&nbsp;posts&nbsp;settings<br \/>&nbsp;*<br \/>&nbsp;*&nbsp;@see&nbsp;latest_posts_form()<br \/>&nbsp;*\/<br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">latest_posts_form<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$form<\/span><span style=\"color: #007700\">,&nbsp;&amp;<\/span><span style=\"color: #0000BB\">$form_state<\/span><span style=\"color: #007700\">)&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$form<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'latest_posts_limit'<\/span><span style=\"color: #007700\">]&nbsp;=&nbsp;array(<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'#type'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #DD0000\">'textfield'<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'#title'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">t<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'Maximum&nbsp;number&nbsp;of&nbsp;posts'<\/span><span style=\"color: #007700\">),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'#default_value'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">variable_get<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'latest_posts_limit'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">3<\/span><span style=\"color: #007700\">),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'#size'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'#maxlength'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">2<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'#description'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">t<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'The&nbsp;maximum&nbsp;number&nbsp;of&nbsp;links&nbsp;to&nbsp;display&nbsp;in&nbsp;the&nbsp;block.'<\/span><span style=\"color: #007700\">),<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #DD0000\">'#required'&nbsp;<\/span><span style=\"color: #007700\">=&gt;&nbsp;<\/span><span style=\"color: #0000BB\">TRUE<\/span><span style=\"color: #007700\">,<br \/>&nbsp;&nbsp;&nbsp;&nbsp;);<br \/>&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">system_settings_form<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">$form<\/span><span style=\"color: #007700\">);<br \/>}<\/span><\/pre>\n<h2>Step 8) Modifying the query<\/h2>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;You should need to modify the <code>recent_posts_contents()<\/code> function. Retrieved the data from the module settings form <code>using variable_get()<\/code> and add the limit to the database query. Modified <code>recent_posts_contents()<\/code> function would be look like the below.<\/p>\n<pre><span style=\"color: #FF8000\">\/**<br \/>&nbsp;*&nbsp;Custom&nbsp;content&nbsp;function.&nbsp;<br \/>&nbsp;*&nbsp;<br \/>&nbsp;*&nbsp;Set&nbsp;beginning&nbsp;and&nbsp;end&nbsp;dates,&nbsp;retrieve&nbsp;the&nbsp;recent&nbsp;posts&nbsp;from&nbsp;the&nbsp;database<br \/>&nbsp;*\/<br \/><\/span><span style=\"color: #007700\">function&nbsp;<\/span><span style=\"color: #0000BB\">recent_posts_contents<\/span><span style=\"color: #007700\">(){<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Get&nbsp;today's&nbsp;date.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$today&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">getdate<\/span><span style=\"color: #007700\">();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Calculate&nbsp;the&nbsp;date&nbsp;a&nbsp;week&nbsp;ago.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$start_time&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">mktime<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,<\/span><span style=\"color: #0000BB\">$today<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'mon'<\/span><span style=\"color: #007700\">],(<\/span><span style=\"color: #0000BB\">$today<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'mday'<\/span><span style=\"color: #007700\">]&nbsp;-&nbsp;<\/span><span style=\"color: #0000BB\">7<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #0000BB\">$today<\/span><span style=\"color: #007700\">[<\/span><span style=\"color: #DD0000\">'year'<\/span><span style=\"color: #007700\">]);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Get&nbsp;all&nbsp;posts&nbsp;from&nbsp;one&nbsp;week&nbsp;ago&nbsp;to&nbsp;the&nbsp;present.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$end_time&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">time<\/span><span style=\"color: #007700\">();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/NEW&nbsp;LINE&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$limit&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">variable_get<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'latest_posts_limit'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">3<\/span><span style=\"color: #007700\">);<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Use&nbsp;Database&nbsp;API&nbsp;to&nbsp;retrieve&nbsp;recent&nbsp;posts.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #0000BB\">$query&nbsp;<\/span><span style=\"color: #007700\">=&nbsp;<\/span><span style=\"color: #0000BB\">db_select<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'node'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'n'<\/span><span style=\"color: #007700\">)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;<\/span><span style=\"color: #0000BB\">fields<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'n'<\/span><span style=\"color: #007700\">,&nbsp;array(<\/span><span style=\"color: #DD0000\">'nid'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'title'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'created'<\/span><span style=\"color: #007700\">))<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;<\/span><span style=\"color: #0000BB\">condition<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'status'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">1<\/span><span style=\"color: #007700\">)&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Published.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">condition<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'created'<\/span><span style=\"color: #007700\">,&nbsp;array(<\/span><span style=\"color: #0000BB\">$start_time<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$end_time<\/span><span style=\"color: #007700\">),&nbsp;<\/span><span style=\"color: #DD0000\">'BETWEEN'<\/span><span style=\"color: #007700\">)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-&gt;<\/span><span style=\"color: #0000BB\">orderBy<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #DD0000\">'created'<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #DD0000\">'DESC'<\/span><span style=\"color: #007700\">)&nbsp;<\/span><span style=\"color: #FF8000\">\/\/Most&nbsp;recent&nbsp;first.<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">range<\/span><span style=\"color: #007700\">(<\/span><span style=\"color: #0000BB\">0<\/span><span style=\"color: #007700\">,&nbsp;<\/span><span style=\"color: #0000BB\">$limit<\/span><span style=\"color: #007700\">)&nbsp;<\/span><span style=\"color: #FF8000\">\/\/NEW&nbsp;LINE<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/span><span style=\"color: #007700\">-&gt;<\/span><span style=\"color: #0000BB\">execute<\/span><span style=\"color: #007700\">();<br \/>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;<\/span><span style=\"color: #0000BB\">$query<\/span><span style=\"color: #007700\">;&nbsp;&nbsp;<br \/>}<\/span><\/pre>\n<p><b>TEST<\/b><\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Go to <b>Configuration&nbsp;&raquo;&nbsp;Performance<\/b>, and click the <b>Clear all caches<\/b> button.<\/p>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Go to the <b>Modules<\/b> listing page <b>=><\/b> Check the checkbox to enable your module <b>=><\/b> Click on <b>Save configuration<\/b>. You&#8217;ll see the <b>Configure<\/b> link along with the module.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-configure-link-by-codexworld.png\" alt=\"drupal-custom-module-configure-link-by-codexworld\" width=\"272\" height=\"92\" class=\"alignnone size-full wp-image-863\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-configure-link-by-codexworld.png 272w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-configure-link-by-codexworld-200x68.png 200w\" sizes=\"auto, (max-width: 272px) 100vw, 272px\" \/><\/div>\n<p><span class=\"glyphicon glyphicon-forward\"><\/span>&nbsp;Click on the <b>Configure<\/b> link, you would be redirected to the module settings page. You can set the maximum number of the posts to be displayed in the block.<\/p>\n<div class=\"img_center\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-settings-form-by-codexworld.png\" alt=\"drupal-custom-module-settings-form-by-codexworld\" width=\"433\" height=\"190\" class=\"alignnone size-full wp-image-864\" srcset=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-settings-form-by-codexworld.png 433w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-settings-form-by-codexworld-300x132.png 300w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-settings-form-by-codexworld-200x88.png 200w, https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-settings-form-by-codexworld-346x152.png 346w\" sizes=\"auto, (max-width: 433px) 100vw, 433px\" \/><\/div>\n<p>Based on this tutorial we have created a Drupal custom module named <b>latest_posts<\/b>. You can download this module from the below <i>Download Source Code<\/i> link.<\/p>\n<p><span class=\"glyphicon glyphicon-saved end-icon\"><\/span>&nbsp;Well done! You have been developed your own module in Drupal 7. We have completed the Drupal module creation tutorial and if you have any query about Drupal custom module development, don&#8217;t hesitate to comment here.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The module helps to extend and customize Drupal functionality. Drupal have three kinds of modules, core, contributed and custom. In this tutorial, you can learn how to create your own module in Drupal 7. Our <\/p>\n","protected":false},"author":1,"featured_media":865,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[11],"tags":[70,69,68],"class_list":["post-856","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-drupal","tag-custom-module","tag-drupal-7-module","tag-drupal-module","cat-11-id","has_thumb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Drupal custom module development tutorial - CodexWorld<\/title>\n<meta name=\"description\" content=\"Drupal module development tutorial for beginners - Learn how to create a custom module in Drupal 7. Step by step guides on Drupal module creation.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Drupal custom module development tutorial - CodexWorld\" \/>\n<meta property=\"og:description\" content=\"Drupal module development tutorial for beginners - Learn how to create a custom module in Drupal 7. Step by step guides on Drupal module creation.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"CodexWorld\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/codexworld\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-02T22:00:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-04-22T16:56:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-development-tutorial-by-codexworld.png\" \/>\n\t<meta property=\"og:image:width\" content=\"787\" \/>\n\t<meta property=\"og:image:height\" content=\"390\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"CodexWorld\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@codexworldblog\" \/>\n<meta name=\"twitter:site\" content=\"@codexworldweb\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"CodexWorld\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/\"},\"author\":{\"name\":\"CodexWorld\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\"},\"headline\":\"Drupal custom module development tutorial\",\"datePublished\":\"2015-10-02T22:00:26+00:00\",\"dateModified\":\"2016-04-22T16:56:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/\"},\"wordCount\":997,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/drupal-custom-module-development-tutorial-by-codexworld.png\",\"keywords\":[\"Custom Module\",\"Drupal 7 Module\",\"Drupal Module\"],\"articleSection\":[\"Drupal\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/\",\"name\":\"Drupal custom module development tutorial - CodexWorld\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/drupal-custom-module-development-tutorial-by-codexworld.png\",\"datePublished\":\"2015-10-02T22:00:26+00:00\",\"dateModified\":\"2016-04-22T16:56:01+00:00\",\"description\":\"Drupal module development tutorial for beginners - Learn how to create a custom module in Drupal 7. Step by step guides on Drupal module creation.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/drupal-custom-module-development-tutorial-by-codexworld.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2015\\\/10\\\/drupal-custom-module-development-tutorial-by-codexworld.png\",\"width\":787,\"height\":390,\"caption\":\"drupal-custom-module-development-tutorial-by-codexworld\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/drupal-custom-module-development-tutorial\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codexworld.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Drupal custom module development tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#website\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"name\":\"CodexWorld\",\"description\":\"Web &amp; Mobile App Development Company\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codexworld.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#organization\",\"name\":\"CodexWorld\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.codexworld.com\\\/wp-content\\\/uploads\\\/2014\\\/09\\\/codexworld-logo.png\",\"width\":200,\"height\":19,\"caption\":\"CodexWorld\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldweb\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/codexworld\",\"https:\\\/\\\/www.youtube.com\\\/codexworld\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codexworld.com\\\/#\\\/schema\\\/person\\\/9da51d8fa3cdefeb5ec9c69136d4baf0\",\"name\":\"CodexWorld\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g\",\"caption\":\"CodexWorld\"},\"description\":\"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.\",\"sameAs\":[\"http:\\\/\\\/www.codexworld.com\",\"https:\\\/\\\/www.facebook.com\\\/codexworld\",\"https:\\\/\\\/x.com\\\/codexworldblog\"],\"url\":\"https:\\\/\\\/www.codexworld.com\\\/author\\\/nitya192265\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Drupal custom module development tutorial - CodexWorld","description":"Drupal module development tutorial for beginners - Learn how to create a custom module in Drupal 7. Step by step guides on Drupal module creation.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Drupal custom module development tutorial - CodexWorld","og_description":"Drupal module development tutorial for beginners - Learn how to create a custom module in Drupal 7. Step by step guides on Drupal module creation.","og_url":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/","og_site_name":"CodexWorld","article_publisher":"https:\/\/www.facebook.com\/codexworld","article_author":"https:\/\/www.facebook.com\/codexworld","article_published_time":"2015-10-02T22:00:26+00:00","article_modified_time":"2016-04-22T16:56:01+00:00","og_image":[{"width":787,"height":390,"url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-development-tutorial-by-codexworld.png","type":"image\/png"}],"author":"CodexWorld","twitter_card":"summary_large_image","twitter_creator":"@codexworldblog","twitter_site":"@codexworldweb","twitter_misc":{"Written by":"CodexWorld","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/#article","isPartOf":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/"},"author":{"name":"CodexWorld","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0"},"headline":"Drupal custom module development tutorial","datePublished":"2015-10-02T22:00:26+00:00","dateModified":"2016-04-22T16:56:01+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/"},"wordCount":997,"commentCount":0,"publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"image":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-development-tutorial-by-codexworld.png","keywords":["Custom Module","Drupal 7 Module","Drupal Module"],"articleSection":["Drupal"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/","url":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/","name":"Drupal custom module development tutorial - CodexWorld","isPartOf":{"@id":"https:\/\/www.codexworld.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-development-tutorial-by-codexworld.png","datePublished":"2015-10-02T22:00:26+00:00","dateModified":"2016-04-22T16:56:01+00:00","description":"Drupal module development tutorial for beginners - Learn how to create a custom module in Drupal 7. Step by step guides on Drupal module creation.","breadcrumb":{"@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/#primaryimage","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-development-tutorial-by-codexworld.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-development-tutorial-by-codexworld.png","width":787,"height":390,"caption":"drupal-custom-module-development-tutorial-by-codexworld"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codexworld.com\/drupal-custom-module-development-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codexworld.com\/"},{"@type":"ListItem","position":2,"name":"Drupal custom module development tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.codexworld.com\/#website","url":"https:\/\/www.codexworld.com\/","name":"CodexWorld","description":"Web &amp; Mobile App Development Company","publisher":{"@id":"https:\/\/www.codexworld.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codexworld.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codexworld.com\/#organization","name":"CodexWorld","url":"https:\/\/www.codexworld.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","contentUrl":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2014\/09\/codexworld-logo.png","width":200,"height":19,"caption":"CodexWorld"},"image":{"@id":"https:\/\/www.codexworld.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldweb","https:\/\/www.linkedin.com\/company\/codexworld","https:\/\/www.youtube.com\/codexworld"]},{"@type":"Person","@id":"https:\/\/www.codexworld.com\/#\/schema\/person\/9da51d8fa3cdefeb5ec9c69136d4baf0","name":"CodexWorld","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cf4999db3b409de559f80677afa01729bb2eeda19be273c254e8b2c22729e386?s=96&r=g","caption":"CodexWorld"},"description":"CodexWorld is a programming blog, one-stop destination for web professionals \u2014 developers, programmers, freelancers, and site owners.","sameAs":["http:\/\/www.codexworld.com","https:\/\/www.facebook.com\/codexworld","https:\/\/x.com\/codexworldblog"],"url":"https:\/\/www.codexworld.com\/author\/nitya192265\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.codexworld.com\/wp-content\/uploads\/2015\/10\/drupal-custom-module-development-tutorial-by-codexworld.png","jetpack_shortlink":"https:\/\/wp.me\/p6bxIh-dO","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/856","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/comments?post=856"}],"version-history":[{"count":5,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/856\/revisions"}],"predecessor-version":[{"id":1442,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/posts\/856\/revisions\/1442"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media\/865"}],"wp:attachment":[{"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/media?parent=856"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/categories?post=856"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codexworld.com\/wp-json\/wp\/v2\/tags?post=856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}