I need to call a php function (located in template.php) inside the teaser of a node, passing node id as parameter.
In the front the function is correctly executed, but also in the back, blocking the page where I can see (and edit) the content of the teaser.
To restore the situation I need to edit the teaser directly in phpmyadmin.

Is there a way to put a php function in teaser without executing it in the backoffice?

Thanks

Comments

jrglasgow’s picture

I don't exactly understand the problem. Are you running into a problem with the php executing on the template edit page?

to avoid this you can always use a disk based template. Also make sure template.php has been included already before you call the function.

jrglasgow’s picture

Status: Active » Postponed (maintainer needs more info)
andrenoronha’s picture

I think what bencio wanted was to call a function located inside template.php from a contemplate.
that's what I need now...

i tried just calling the function in the contemplate but the function wasn't reconized...
is there a way to do this or do I have to redeclare the whole function insite the contemplate?

andrenoronha’s picture

ok, i saw in here http://drupal.org/node/502888 that it only affects the config of contemplate.
that's because the function inside template.php only works for my custom theme.

is there a way to make it works without having to declare it in the template.php of my admin theme?

jrglasgow’s picture

you could do it this way:

include_once(drupal_get_path('theme', 'theme_name') .'/template.php');
function_name();

this will include the template.php file for your theme and then you can execute any functions necessary....

if the function in tempalte.php is a theme function like themename_table you can just:

theme('table', args...);

and the theme function will be called

andrenoronha’s picture

hey jrglasgow thanks

but i made my own solution...
i'm checking if the function is declared before calling it with function_exists('my_function')