{"id":1762,"date":"2014-01-26T11:02:27","date_gmt":"2014-01-26T09:02:27","guid":{"rendered":"http:\/\/www.extradrm.com\/?p=1762"},"modified":"2014-01-27T15:48:11","modified_gmt":"2014-01-27T13:48:11","slug":"create-module-drupal-7-part-2","status":"publish","type":"post","link":"https:\/\/www.extradrm.com\/?p=1762","title":{"rendered":"Create Module Drupal 7 &#8211; Part 2"},"content":{"rendered":"<p>In this tutorial, we will continue Drupal developpement sample of our module called myblock <strong><a title=\"Creating a Drupal 7 module from scratch\" href=\"http:\/\/www.extradrm.com\/?p=1719\">in part 1<\/a>.<\/strong><br \/>\nBy implementing hook_help(), a module can make documentation available to the user for the module as a whole, or for<\/p>\n<p>specific paths. For our example myblock module let us write this hook below :<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_help.jpg\"><img loading=\"lazy\" alt=\"myblock_help\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_help.jpg\" width=\"676\" height=\"201\" \/><\/a><\/p>\n<p>It will display &#8220;<strong>Help<\/strong>&#8221; the following in Module details<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_admin.jpg\"><img loading=\"lazy\" alt=\"myblock_admin\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_admin.jpg\" width=\"711\" height=\"114\" \/><\/a><\/p>\n<p>If we click on <strong>help<\/strong> we will have a documentation detail for our drupal module as below :<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_admin_help.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1765\" alt=\"myblock_admin_help\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_admin_help.jpg\" width=\"530\" height=\"241\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_admin_help.jpg 530w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_admin_help-300x136.jpg 300w\" sizes=\"(max-width: 530px) 100vw, 530px\" \/><\/a><\/p>\n<h1 class=\"title\" id=\"page-title\"><!--more-->hook_permission<\/h1>\n<p>This hook can supply permissions that the module defines, so that they can be selected on the user permissions page and used to grant or restrict access to actions the module performs. the array <strong>access mypage <\/strong>is the link between myblock_menu and myblock_permission.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_menu.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1768\" alt=\"myblock_menu\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_menu.jpg\" width=\"577\" height=\"617\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_menu.jpg 577w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_menu-280x300.jpg 280w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/a><\/p>\n<p>When module myblock is installed no permissions are in place so we get an <strong>unauthorized<\/strong> access to the meny ressource <strong>mypage<\/strong>.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_no_permission.jpg\"><img loading=\"lazy\" alt=\"myblock_no_permission\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_no_permission.jpg\" width=\"703\" height=\"359\" \/><\/a><\/p>\n<p>When module myblock permissions are allowed\u00a0 so we get an <strong>authorized access<\/strong> to the meny ressource <strong>mypage<\/strong>.<\/p>\n<p><a href=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_menu1.jpg\"><img loading=\"lazy\" class=\"aligncenter size-full wp-image-1767\" alt=\"myblock_menu1\" src=\"http:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_menu1.jpg\" width=\"679\" height=\"553\" srcset=\"https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_menu1.jpg 679w, https:\/\/www.extradrm.com\/wp-content\/uploads\/2014\/01\/myblock_menu1-300x244.jpg 300w\" sizes=\"(max-width: 679px) 100vw, 679px\" \/><\/a><\/p>\n<p>Hope this tutorial will help you to start in drupal 7 developpement module with more confidence.<\/p>\n<p>Cheers,<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, we will continue Drupal developpement sample of our module called myblock in part 1. By implementing hook_help(), a module can make documentation available to the user for the module as a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":2842,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[139,6],"tags":[259],"youtube_video":null,"_links":{"self":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1762"}],"collection":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1762"}],"version-history":[{"count":0,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/posts\/1762\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=\/wp\/v2\/media\/2842"}],"wp:attachment":[{"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1762"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1762"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.extradrm.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1762"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}