0

I'm trying to set up entity autoloading using hook_menu like this:

    $menu['e-shop/produkt/detail/%commerce_datasheet'] = array(
    'title' => t('Products'),
    'page_callback' => 'commerce_products_datasheet_detail',
    'page_arguments' => array(3),
    'access callback' => TRUE,
     );

function commerce_datasheet_load($datasheet_id) {
  return entity_load_single('commerce_datasheet',$datasheet_id);
}

function commerce_products_datasheet_detail($entity, $view_mode='full') {
    dpm($entity); 
}

dpm() function doesn't return anything, so I assume, that $entity is empty.

I am using latest versions on Drupal 7 and Entity API module.

4
  • 1
    It's page callback and page arguments, no underscores
    – Clive
    Jun 16, 2016 at 21:07
  • @Clive: Thanks, you're right, of course. I still wasn't able to solve my problem, but at least this is corrected. Jun 16, 2016 at 21:22
  • Oh, you probably need to return something from the page callback too to invoke the theme handler. Your menu/load stuff looks fine to me, that should be working
    – Clive
    Jun 16, 2016 at 21:35
  • @Clive: Yes, you're right. Details are in the answer, if you're interested in my mistake... Jun 16, 2016 at 22:35

1 Answer 1

1

It was my mistake. I was using another module, which provided page callback with higher priority. For the next time - it's advisable to install devel module and go to devel/menu/item?path=<uri> where used page callback can be clearly seen.

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.