By jameson on
As soon as the ?php print $content? is removed from the template and the '?php print content_format('field_whatever', $field_whatever[0]); ?' inserted then the ability to use CCK's Teaser view and Full view is lost.
For example in my content type I have a field_short_description set to display in Teaser while for Full it is Hidden.
How would I get the below script to understand CCK's Teaser and Full?
print content_format('field_short_description', $field_short_description[0]);
print content_format('field_description', $field_description[0]);
Does anyone have an example piece of code that will pick up cck's field displays - teaser and full?
Much appreciated.
Comments
contemplate module have the
contemplate module have the ability to set different templates for both teasers and nodes.
<?php print
<?php print $node->content['field_field_name']['#value'] ?>I think it becomes something similar
[#value] only prints the
[#value] only prints the value of the field. So if it has a special formatting, it won't be formatted with that.
$field_name[0]['view']
I believe $field_name[0]['view'] has the formatted text. So if the name of the cck field you created is foo, then $foo_field[0]['view'] contains the formatted text you want.
There is a helpful function which displays all available variables for you in a .tpl.php file, you'll have to see if you can find it here, I don't remember the location in the handbook where it describes it.
Dave
My site: http://www.unitorganizer.com/myblog
lol i just saw that !! lemme
lol i just saw that !! lemme check history
BTW, how do u format a field?? oh i think i might have seen that too
EDIT3: http://drupal.org/node/191796
how do u format a CCK field?
how do u format a CCK field?
I did exactly what you want to do:)
Hi there....
Take a look at this very helpful link: http://www.davidnewkerk.com/book/30
Read the section on "Custom theming for node-article.tpl.php". It will tell you what you need to replace the
<?php print $content ?>with. You can replace it with<?php print $node->content['body']['#value'] ?>for the full node section of your node.tpl.php. (Read further below and this will make more sense to you:)(In fact, I would bookmark David's website...it has a LOT of VERY VERY handy info up there!! It really helped me out when putting my site together.)
Here is an example of some code STRUCTURE for your node.tpl.php section you can use as an example template (given to me by yelvington, another user.) I modified this for each of my sections on my site. I used this (along w Views and CCK) to customize how I wanted my teasers vs my full View/node to look.
In Views, I chose to display the View (of each section) as node, and not fields, then customized the node.tpl.php to get it to look exactly the way I wanted.
Here is an example of one of my node.tpl.php files, the one for my articles section (for the teasers and full node) at (you can view how it looks at http://74.220.215.68/~leemagaz/articles . Pls. note that it is currently under heavy construction so most of the text in the stories is just "dummy text" :) :
I hope this helps!!
P.S. Imagecache & Imagefield were used in tandem with CCK for the teaser & main images:)
My other thread here at http://drupal.org/node/290667 may be of additional help to you:) That was as I was trying to customise the node.tpl.php to get everything the right place.
Best regards,
Christine
P.P.S. I just saw your post was a month old! I hope this will still be of SOME help at least:) Better late than never...
Would this help?
Would this help? http://drupal.org/node/92382