drupal 7 - Access $block inside Block body field that has PHP evaluator enabled

994

In template.php, I've added a variable to$block via$vars['block']->member_login_url, insidetheme_preprocess_block.

I can access this variable in theblock.tpl.php by:<?php print $block->member_login_url; ?>, but I would like to access it in the GUI block edit screen in Drupal (screenshot below of where I'm getting undefined variable errors).

The body field is using a text type with 'PHP Evaluator' enabled, but for some reason I can't figure out how to access Drupal variables, or block variables.

getting variable error

406

Answer

Solution:

I am not sure why you are assigning the value using object notation. I would have used$vars['block']['member_login_url'] = blah and then access the variable using$member_login_url in the tpl file, but you can output the available variables in the template using the php functionget_defined_vars()

People are also looking for solutions to the problem: html - PHP sorting an array into two columns

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.