Hi,
I have picked up this snippet from nicklewis.org that creates CCK teasers, I put it into template.php:
function _phptemplate_variables($hook, $vars) {
global $user;
switch ($hook) {
case 'node':
if ($vars['field_summary_of_your_experienc'][0]['value']) {
/* Believe it or not, all you have to do is pass the field through
the existing node.module function node_teaser()! */
$vars['cck_teaser'] = node_teaser($vars['field_summary_of_your_experienc'][0]['value'], $format = NULL);
}
break;
}
return $vars;
}
I can call these teasers in node.tpl.php with this code:
if ($teaser) {
print $cck_teaser;
$readmore_link = '<a href="' . $node_url . '" title="' . $title.'">' . t('read more') . '</a>' . ' | ';
}
else {
print $content;
$readmore_link = "";
}
..thereby displaying them on the frontpage, and this works fine. However, I also have a Views page that is supposed to list teasers in a list view. So I made a Views template file with the theme wizard and replaced the body variable with the this code snippet:
print $cck_teaser;
$readmore_link = '<a href="' . $node_url . '" title="' . $title.'">' . t('read more') . '</a>' . ' | ';
and it doesn't work :(
$cck_teaser is apparently not available in my views-list-Reviews.tpl.php file. My question, how do I make my teaser available to other tpl.php files, rather then just node.tpl.php?
Hopefully someone can help me with this because I've tried a lot, without success.
Regards,
JR
Apparenty
Comments
this is a good question...anyone?
peach this is a good question...anyone ?