By cschall on
I have a flexinode for a newsletter that I created where I don't want to display the node title, rather I would like the user to create a custom title. Will node.tpl.php control that? If so, can I modify node.tpl.php to not show titles for a specific flexinode?
In node.tpl.php I have this, but I must have the syntax wrong because I can still see the title.
<?php if ($page == 0): ?>
<?php if(type != 'flexinode-2') :?>
<h2 class="title"><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
<?php endif; ?>
<?php endif; ?>
Thanks.
Comments
Typo and another approach
In the code you show
type != 'flexinode-2'should be$node->type != 'flexinode-2'.You can also create a template file just for your content type, in this case you could copy node.tpl.php to node-flexinode-2.tpl.php and make the changes in the new file which would only apply to content of type flexinode-2.
title removal didn't work
I have the node-flexindode-2.tpl.php file to display my content, but I don't actually even have the title field displayed. I think that the node title is controlled differently which is why I thought that I needed to do the edit in the node.tpl.php file.
But that being said, I modified my file as indicated and I still see the title.
Here's the updated code.
THANKS.
Two places where title is printed
The title is printed in one of two places depending in the context, a single node (i.e. page) or a list of nodes. The changes to node.tpl.php (or node-flexinode-2.tpl.php effect the title for the case of a list of nodes. For the title of a single node you will need to look at page.tpl.php. Look for $title.
Perfect - Got It!
Thanks so much!
does no take effect!!!!
I did a search for $title and found this:
will you please let me know how can i get rid of the page title?
How about with Marvin?
I'm using Marvin, and want to change the title display on my pages of a certain type to a custom one. Marvin doesn't seem to *have* a page.tpl.php file, so I can't see anywhere to change it. Any ideas?
You do not say which version
Marvin comes in several versions (different names) that work on various versions on Drupal.
For MarvinClassic, look in marvinclassic.theme for the function marvinclassic_node and look for $node->title,
Both Marvin 2K and Marvin 2K for PHPtemplate should have a node.tpl.php
okay i've edited
okay i've edited chameleon.theme which is where i found the <h2> title line. My problem now is I don't know how to put what type of node is currently loaded into the if. I want to display a custom title (<h2>) on my 'content-property' nodes, so I put the following into chameleon.theme:
but this did nothing - it just always displays $title. So then i even tried putting
into the code, but it doesn't display any text after the ':', suggesting that it can't access $node->type from that file.
Any suggestions?
$node not available in .theme files (except in _node function)
You do node say which function you modified but from your comments it sounds like chameleon_page() where $node iis not available so you need to change your logic to something like this
which loads the node if a single node is being viewed.
That's the one - almost there!
Thanks for that - you were spot on.
My only problem now is that I wanted the title to include variables which, when in the node, I got thus:
<h2>".$node->field_road[0]['view'].", ".$node->field_postcode[0]['view'].", ".$node->title."</h2>Of course, using that code in the theme file doesn't give any output. So is there a way I can access these variables from the theme file?
Something to try
If you add this to your code
print '<code>' . print_r($node, TRUE) . '';you will be able to see all the fields available in $node.
Many thanks!
That seems to have fixed it! Thanks!