By rewted on
I've created a custom field named $field_get_help. It is an integer Single on/off checkbox with these values:
display|Display Help Box
hide|Hide Help Box
The default "display" should show my HTML listed below, but if "hide" is checked, then DO NOT display the HTML on page.
Can anyone tell me what PHP if statements I'd need in my node template do accomplish this?
HTML to be show by default:
<div class="help_box">
<div class="ghn"><b>Need help?</b><br/>
<a href="/help">Get help now</a>
</div>
</div>
Comments
There should already be some
There should already be some similar examples in the default node template for various things like the links and whatnot..
But, you essentially need an if statement to check the value of your field, and output the appropriate html when necessary.
I'd suggest installing the devel module, and using the dpm() function to inspect the node object in your template to be sure you understand the structure and everything completely.. The code you'll ultimately need should be similar to the following:
EDIT: Looks like you changed your original post, causing my sample code to not make any sense. Removed.
Follow me on twitter.
Yes, sorry. I had to clarify
Yes, sorry. I had to clarify my post a little better. The suggestion by Phryk works in preview, but fails to display once the article is saved. Do you know why?
Still can't figure out the
Still can't figure out the proper way to do this, looking for more assistance.
Any further insight?
Any further insight?
The field (as least in my
The field (as least in my experience with D6 + CCK) should be in $node->field_get_help,
this should be an array of arrays, each of the inner array is associative and holding the values associated with a filled field.
Okay that might be a bit confusing (most likely due to my grammar). Here's a notation of what a text-field could look like:
This is not totally accurate, but should help imagine you how it's built.
Seeing this you can access the value of the first text ('sometext') with $node->field_sometext[0]['value']
So you should be able to do something like this:
The print displays during
The print displays during preview, but once saved, doesn't show up in the article. Any idea why?
Problem solved.
Found the issue. It was because I initially set the checkbox as an integer, so using "display" will not work. Deleting, re-creating as text, display now works. Another solution would be changing the checkbox to a number.
_
Please don't post duplicate threads, I've deleted the dupe(s). Thanks.
I'm not. The other post is
I'm not. The other post is related to display issues in preview vs saving.