Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
jrglasgow CreditAttribution: jrglasgow commentedI 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.
Comment #2
jrglasgow CreditAttribution: jrglasgow commentedComment #3
andrenoronha CreditAttribution: andrenoronha commentedI 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?
Comment #4
andrenoronha CreditAttribution: andrenoronha commentedok, 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?
Comment #5
jrglasgow CreditAttribution: jrglasgow commentedyou could do it this way:
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:
and the theme function will be called
Comment #6
andrenoronha CreditAttribution: andrenoronha commentedhey jrglasgow thanks
but i made my own solution...
i'm checking if the function is declared before calling it with function_exists('my_function')