How to call a php function inside teaser

Bencio - October 2, 2008 - 08:53
Project:Content Templates (Contemplate)
Version:5.x-2.02
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:postponed (maintainer needs more info)
Description

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

#1

jrglasgow - October 2, 2008 - 22:27

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.

#2

jrglasgow - October 2, 2008 - 22:30
Status:active» postponed (maintainer needs more info)

#3

a.luiz.n - September 8, 2009 - 20:30

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?

#4

a.luiz.n - September 8, 2009 - 20:35

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?

#5

jrglasgow - September 10, 2009 - 22:42

you could do it this way:

<?php
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:

<?php
theme
('table', args...);
?>

and the theme function will be called

#6

a.luiz.n - September 11, 2009 - 16:54

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')

 
 

Drupal is a registered trademark of Dries Buytaert.