2

I am trying to create a menu with a file extension in hook_menu() with the following code:

$items['pdf/products/%.pdf'] = array(
    'title' => 'Download PDF',
    'page callback' => '_pdf_get',
    'page arguments' => array(2),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK
);

It works fine without the .pdf.

Any ideas how I can do this?

2
  • possible duplicate of How to handle URLs like node/%.atom?
    – avpaderno
    Commented Jul 14, 2011 at 15:56
  • The answer to this question has been already provided in another question; the difference is the extension, but the answers given for that question already cover this case.
    – avpaderno
    Commented Jul 14, 2011 at 15:57

1 Answer 1

3

Why do you need the .pdf part in the hook menu? Can't you just perform a check on the arg() function in your _pdf_get function to ensure that the argument contains ".pdf" and if not, redirects the user to the url with ".pdf" appended?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.