What is wrong?

Events happening in the community are now at Drupal community events on www.drupal.org.
eugen80's picture

Hi,

i'm new to rules, i'd like to set a var on one page (an author-id) and read it on next page.
If i try to echo or var_dump the created var, i get NO output (even lines like echo "hello"). http://pastebin.com/m7677e84d What am i doing wrong?

Comments

If you're talking about D7,

jmroth's picture

If you're talking about D7, then probably output buffering is used.
Use e.g. ob_flush() after your var_dump() to display.

dpm

itangalo's picture

I don't know much PHP, but I've seen developers using the function dpm($whatever) to get a nice printout of Drupal variables. To use this you must have the Devel module installed.

Consider the function an extended print_r that fits well in Drupal.

//Johan Falk, Sweden

Re: dpm

jmroth's picture

Yep the devel module is worth a try but I'm not sure if entire arrays will be nicely output in a call to drupal_set_message() which is used by dsm() / dpm().

Ok, another take

itangalo's picture

If I understand the situation correctly you are doing two things that make your problem unneccessarily complicated:

  1. You're saving the information to be shown in a global variable in the database.
  2. You're printing the variable with PHP print/echo instead of using Drupal's internal messaging system.

What I recommend doing:

  1. On the triggering event, make an action "show a configurable message on the site" (under "System").
  2. Use tokens as much as you can to configure this message. Avoid PHP if it is not neccessary.

The message will automatically be displayed to the user on the next page load, so there is no need to save it (manually) in any variable.

I hope this might clarify things...
Good luck!
//Johan Falk, NodeOne, Sweden

Rules

Group organizers

Group categories

Categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: