Hi all,
Can someone give me a brief explanation of what exactly the differences are between 'value' vs 'safe' vs 'view' vs 'format'? I really am having a very hard time finding good documentation on this that is written in plain english...
For example, I have created several different fields in my content types and modified the node.tpl.php file/s to accommodate these fields. HOWEVER, the way I have been modifying them is by experimenting with cutting and pasting to get things in the right place and as I want them. Due to my severe lack of knowledge with php (which I am REALLY trying to work on!:) there are a few minor things that are not working right. For example, I have specified within the CCK module for some of those fields to have the option of being FULL HTML but when creating the content and choosing the "FULL HTML" option, things are not working as expected and it is completely ignoring my HTML. Yet it works PROPERLY on some other fields, as it should. I have everything else set up properly so I am quite sure the fault is with my modified node.tpl.php.
I then popped over to the contemplate module to take a look at some of the recommend php tags and I am completely confused as to which I should select.
For example, I have a field for a cutline for the main image that I want to be full html.
Here are the options given in contemplate:
$node->field_image_primarytext[0]['value'] ** (NULL)
$node->field_image_primarytext[0]['safe']
$node->field_image_primarytext[0]['view']
I don't know which to choose?
What does this message mean in reference to the line with the asterisks above...
Click property to add to your template. Fields marked with ** are insecure and need to be wrapped with either check_plain() or check_markup()
Here is my actual code for the image_primarytext field from my node.tpl.php that didn't work with full html(I prolly also need to change the 'span' to just a 'div' or 'p'...but didn't work with that either) :
<?php if ($field_image_primary or $field_image_primarytext): ?>
<div id="image_primary_main">
<?php print $node->field_image_primary[0]['view'] ?>
<span class="cutline"><?php print $node->field_image_primarytext[0]['view'] ?></span>
</div>
<?php endif; ?>
I have another field for the teaser text.
Here are my options in Contemplate:
$node->field_article_teaser_text[0]['value'] **
<strong>August 2008</strong>
$node->field_article_teaser_text[0]['format']
2
$node->field_article_teaser_text[0]['safe']
<p><strong>August 2008</strong></p>
$node->field_article_teaser_text[0]['view']
The teaser text actually works as it SHOULD with full html. Here is the code from my node.tpl.php:
<?php print $node->field_article_teaser_text[0]['view'] ?>
Please can you help clear this brainfog for me?
Thank you very much in advance for your assistance!
Christine
Comments
Can anyone shed some light on this for me?
Okay...so after a ton of experimenting, changing 'view' to 'value' in that field now lets the full html works as it should. However, I still don't know exactly what those fields mean and still cannot find adequate documentation on it.
Can someone just give me a very brief explanation?
For example, does 'view' refer to an image? does 'value' mean full or filtered html?
Dumb questions I know, but so essential for me to understand things more. Just knowing the answer to this will help me a whole lot more when customizing things in the tpl.php files.
(P.S. I DO plan on doing some intense php tutorials in the near future)
Christine
If you use view, it will
If you use view, it will provide apply the settings for the field you give in content types >> your content type >> display fields.
For example, if you want a certain field to appear hidden/or another format if using the date field (short date 8/2/2008 or medium August 2nd, 2008) you can control the way the field is displayed on teaser and full node views when using the view , and I don't think you can with value .
Also, you can print fields like this
What would go in place of the words "content_format" ?
Thanks Prodigy...
I tried using the code you provided to print one of my image fields
and all I got was the image filename showing up with a link to the image and not the actual image itself.
What would go in place of the words "content_format" ?
Christine