tags:

views:

893

answers:

1

I have a page that is definitely not a form but I need to use some callback functions to load data from an external source and display (e.g. a list of buildings on campus and their accessibility information).

What I have a need for is a landing listing page (lists all the buildings) and a 'view individual building' page. Also, I have a page where you punch in your student ID and view information on testing procedures. And finally I have a page that is basically a form (which I have done before successfully in the past).

Now, I HAD the building list working, however I made a small change and it stopped working!

Currently my hook_menu() function looks as below:

<?php
/**
 * Implementation of hook_menu()
 */
function disability_menu()
{
    $items = array();

    // Ignore me, shell
    $items['quickreg'] = array(
        'title' => 'Quick Registration',
        'description' => t(''),

        'page callback' => 'drupal_get_form',
        'page arguments' => array(),
        'file' => 'disability.quickreg.view.inc',

        'access arguments' => array('access quick registration system'),

        'type' => MENU_SUGGESTED_ITEM,
    );

    $items['tests/status'] = array(
        'title' => 'Test Status Results',
        'description' => t('Check on the status of your tests'),

        'page callback' => 'disability_view_testing_status',
        'page arguments' => array(),
        'file' => 'disability.tests.view.inc',

        'access arguments' => array('access test check information'),

        'type' => MENU_CALLBACK,
    );

    $items['tests'] = array(
        'title' => 'Testing Services',
        'description' => t('Check on the status of your tests'),

        'page callback' => 'disability_view_testing',
        'page arguments' => array(),
        'file' => 'disability.tests.view.inc',

        'access arguments' => array('access test check information'),

        'type' => MENU_SUGGESTED_ITEM,
    );

    $items['access/%building'] = array(
        'title' => 'Campus Accessibility Guide',
        'description' => t('A summary list of detailed accessibliity information about each building on the A&M campus'),

        'page callback' => 'disability_view_access',
        'page arguments' => array(1),
        'file' => 'disability.access.view.inc',

        'access arguments' => array('access building access information'),

        'type' => MENU_SUGGESTED_ITEM,
    );

    return $items;
}

Before some change I must have made the menu item for "Campus Accessibility Guide" would show up properly (after being enabled of course). The /access url would work correctly displaying a list of all building and the /access/12345 would correctly display the single record of ID# 12345.

Now the access/%building menu entry is not even showing up and even sending the url /access into a redirect loop (making me think it's passing in something for the ID which sends it into the view specific function that redirects to /access when the ID doesn't exist).

Can anyone tell me what I'm doing wrong or what I need to do to support 2 themed pages: a /access and /access/%building url pattern?

+1  A: 

You should only use %name instead of % in urls when you have a function that you want to act on the url. Drupal does this all over the place with user and node, and this is very smart, as you only one place need to have the code to load an user or a node, but it get used in a lot of places. In this case I bet it's a bit overkill to make a function to load the building. On the other hand the advantage is that doing it that way, you get the 404 handling, if no object can be found. The best solution really comes down to how you want to handle buildings that does not exist. You could even make your 'Campus Accessibility Guide' function handle the 404 which would make the two options more or less equal. I would go for whatever is easiest for you to make.

googletorp
Now when I change it to `$items['access/%'] = //...` it still no longer shows up in the menu list...
dcousineau
Never mind, I added a new menu entry with just access (now have access and access/% pointing to their respective functions). It works now!
dcousineau