Active
Project:
Content Templates (Contemplate)
Version:
5.x-1.8
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
2 Mar 2008 at 03:37 UTC
Updated:
2 Mar 2008 at 15:00 UTC
Is this possible? If I define $vars['sample_variable'] in template.php, and I try to insert this in a Contemplate template using print $sample_variable;, nothing prints. Is there another way I'm supposed to do this? Thanks.
Comments
Comment #1
jrglasgow commentedWhat type of variables are you trying to use in Contemplate? What is your final goal?
You definitely could do this if you included the template file first, i.e..
Also you can just create a node-nodetype-field.tpl.php, check out the documentation at 'admin/help/contemplate#disk-based'
Comment #2
akahn commentedI'm using $node variables that are part of the event module. I'm trying to take the event_start and event_end variables (e.g. 200803011800 aka March 1, 2008, 6pm) that the module supplies to create a variable that contains a human-readable date, (such as March 1, 2008), along with variables for the start and end time (such as 6pm). I am doing this in the contemplate fields at the moment, but I thought it might be more efficient to do this in template.php (so it wouldn't be done for every single node teaser in a view). Is this correct, or am I misguided?
Thanks for the tips on including template.php. I'll try going in this direction.
Comment #3
jrglasgow commentedon the template edit page you have the textarea where you add the template for teaser, body and rss. under each of these areas there is a dropdown link that will show you another text area with a list of the available variables, this link is titled: teaser variables, body variables and rss variables. These variables do include
$node->event_start,$node->event_end, etc... of course this is only for events that have those variables.It is possible to use
$node->event_startin the body template and not in the teaser template.Comment #4
akahn commentedRight, but if I want to make a custom variable, $date, a human-readable string based on $node->event_start, wouldn't I want to do this in template.php rather than right in Contemplate's teaser and body textareas?
Comment #5
jrglasgow commentedI guess I don't see any reason right now why you couldn't. I'm just saying it would be easy enough to do it in Contemplate with