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) »
  • Newbie hook question, pageRun
Pages: [1]

Author Topic: Newbie hook question, pageRun  (Read 1493 times)

hlevinson

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 3
Newbie hook question, pageRun
June 18, 2009, 04:34:49 pm
I'm having trouble trying out hooks (CiviCRM 2.2.5 with Drupal 6.12)

I created harry.module and harry.info.

harry.module contains a simple function named

   harry_civicrm_pageRun

with one line of code

   $page->assign( 'varName', 'Harry variable assigned by the hook' );


In my block, which I placed in the footer, I used this

   <?php echo $varName; ?>

However after I save all that, when I view my pages my block title and my data never appear, and there's no error message.

If I replace the block code with something like this it does display the block title and the year:

   <?php echo date('Y'); ?>

I tried putting my 2 files in various places such as

/var/www/sites/dv01/modules
/var/www/sites/dv01/modules/civicrm/drupal

and the Modules section in Drupal found it either way, so I enabled the module.

I'm new to PHP, Drupal, and CiviCRM, so perhaps I'm missing something simple?

Harry Levinson

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Newbie hook question, pageRun
June 18, 2009, 07:05:40 pm

hey harry:

you will also need to customize a tpl to display the variable.

Check:

http://wiki.civicrm.org/confluence/display/CRMDOC/Customize+Built-in,+Profile,+Contribution+and+Event+Registration+Screens

Modify the tpl where you want to display varName and you can display it by adding

{$varName}

to the tpl file. Ping us on IRC (http://tinyurl.com/civiirc) if u need assistance

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

hlevinson

  • I post occasionally
  • **
  • Posts: 53
  • Karma: 3
Re: Newbie hook question, pageRun
June 19, 2009, 08:29:11 am
Hey Lobo, you still rock!

I followed the instructions and can see my variable contents displayed correctly.

You guys have done a fantastic job... still digging into stuff to learn how it all works.

Harry

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

This forum was archived on 2017-11-26.