CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_xmlMenu
Pages: [1]

Author Topic: hook_civicrm_xmlMenu  (Read 987 times)

muenzer

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
hook_civicrm_xmlMenu
August 15, 2010, 06:27:59 pm
Is there anyway I can check if my hook_civicrm_xmlMenu is being called?  The items in the menu file don't seem to be working, but I can't figure out what I did wrong.

muenzer

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
Re: hook_civicrm_xmlMenu
August 18, 2010, 07:05:53 pm
Can anyone take a look at this simple module code and let me know if I'm doing anything wrong.  It doesn't seem like the civicrm_xmlMenu hook is working.  I'm just trying to implement the code from this example:
http://wiki.civicrm.org/confluence/display/CRMDOC32/Five+simple+steps+to+creating+a+settings+page+for+your+module+or+custom+forms

Code: [Select]
<?php

function test_civicrm_config( &$config ) {
$template =& CRM_Core_Smarty::singleton( );

$root = 
drupal_get_path('module', 'test') . DIRECTORY_SEPARATOR;

$dir = $root . 'templates';

if ( is_array( $template->template_dir ) ) {
array_unshift( $template->template_dir, $dir );
} else {
$template->template_dir = array( $dir, $template->template_dir );
}

// also fix php include path
$include_path = $root . PATH_SEPARATOR . get_include_path( );
set_include_path( $include_path );
}

function 
test_civicrm_xmlMenu( &$files ) {
$files[] = drupal_get_path('module', 'test') . "/test.menu.xml";
}

I tried to upload a zip file of the full test module, but the forum didn't let me.


Thanks in advance.

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: hook_civicrm_xmlMenu
August 18, 2010, 07:19:46 pm
I probably should have added a step to rebuild the menu to that doc. Not sure if it's necessary or not. Can you visit <site>/civicrm/menu/rebuild&reset=1 and then retry?

muenzer

  • I’m new here
  • *
  • Posts: 13
  • Karma: 1
Re: hook_civicrm_xmlMenu
August 19, 2010, 06:13:30 pm
Thank you, that was the missing step.  I kept reinstalling the module and and rebuilding the menu through the Devel module, but never did the Civicrm rebuild menu command.  Thank you again.  There was lots of banging my head against the wall on that one. 

Can that get added to the hook documentation page?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: hook_civicrm_xmlMenu
August 19, 2010, 09:30:10 pm
Added.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • hook_civicrm_xmlMenu

This forum was archived on 2017-11-26.