views:

22

answers:

1

I have a PDF burried in a module (sites/all/modules/mymodule/pdf/userguide.pdf)....how do i make it a friendly url like (sitename.com/mymodule/userguide.pdf) ?

+1  A: 

or in your module code next:

/**
 * Implementation of hook_menu()
 */
function mymodule_menu() {
  $items['mymodule'] = array(
    'page callback' => 'mymodule_pdf',
    'type' => MENU_CALLBACK,
    'access arguments' => array('access content'),
    'page arguments' => array(1),
  );
  ...
  return $items;
}

function mymodule_pdf ($filename) {
// function that will upload generated $filename.pdf
}

p.s. Also you can try add alias via path module, map: sites/all/modules/mymodule/pdf/userguide.pdf to mymodule/userguide.pdf...

Nikit
Note, though, that serving files trough PHP is a **lot** slower and heavier then serving it trough Apache. by default, if Apache finds a "fysical file" it will serve it right away, with hardly any overhead (happens for CSS, Js, images etc.) and if not found, it will hand over to Drupal, wich needs to be booted, compiled, evaluated and ran.
berkes

related questions