Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>What you are doing so far is mostly correct (The "title" key is <strong>required</strong> for each item, so be sure to include that). Since the <code>page callback</code> is directed at <code>mymodule_landing()</code>, the content returned from that function will be displayed as your content on the page. </p> <p>To make more pages (like step2, step99, etc) you would continue with creating more paths in <code>mymodule_menu()</code> like:</p> <pre><code>$items['mymodule/step2'] = array( 'title' =&gt; 'Step 2', // Required 'page callback' =&gt; 'mymodule_step2', 'access arguments' =&gt; array('access content'), 'type' =&gt; MENU_NORMAL_ITEM, ); </code></pre> <p>And so forth... You <em>could</em> use the same page callback <code>mymodule_landing()</code> and simply pass "page arguments" or each can have its own page callback.</p> <p>To put your function <code>mymodule_landing()</code> in a separate file, you can use the <em>file</em> and <em>file path</em> keys (see below)</p> <pre><code> $items['mymodule/landingpage'] = array( 'title' =&gt; 'Landing Page', // Required 'page callback' =&gt; 'mymodule_landing', 'access arguments' =&gt; array('access content'), 'type' =&gt; MENU_NORMAL_ITEM, 'file' =&gt; 'mymodule.pages.inc', 'file path' =&gt; drupal_get_path('module', 'mymodule'), ); </code></pre> <p>You should put these files in your module directory (or sub-directory inside module directory and set the correct <em>file path</em>) and can access each page at <code>mysite.com/mymodule/landingpage</code>, <code>mysite.com/mymodule/step2</code>, etc.</p> <p><strong>Best Practices for Page Handler Include Files</strong> (read more at <a href="http://drupal.org/node/146172">http://drupal.org/node/146172</a>):</p> <blockquote> <p>Module developers are free to split off page handlers for their modules however they choose. However, the following guidelines and standards are recommended:</p> <ul> <li>Any module that has more than ~50 lines of code for page handler functions (including form handling functions if applicable) should split them off into a separate file. That reduces the overhead for PHP when loading modules, and therefore speeds up every single request on the site.</li> <li>Page include files should be named in the form modulename.key.inc, where "modulename" is the name of the module and "key" is a one-word descriptive term for the types of page handlers it includes.</li> <li>For most modules, splitting page handlers into two files -- example.admin.inc (for administrator-only pages) and example.pages.inc (for pages accessible by non-administrator users) -- is sufficient, and is the recommended practice. If a module has no non-administrator pages, it should just have a single example.admin.inc file. If a module has no administrator-only pages, it should just have a single example.pages.inc file.</li> <li>Modules that have a large number of page handlers may choose to separate out page handlers even further. If so, each file should be grouped logically by function (for instance, admin pages related to theming, admin pages related to logging, other admin pages, and user-accessible pages) and clearly marked. Remember that splitting the module's page handlers up too far makes maintenance more difficult, and only one page handler include file is ever loaded regardless of how finely-grained the handler functions are separated.</li> </ul> </blockquote> <p>Added just for reference: <a href="http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_menu/6">hook_menu() documentation</a></p> <p>The <a href="http://api.drupal.org/api/examples/page_example--page_example.module/6">page_example.module</a> may also be of help to you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload