Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By adrianqx on
I have a page node template named page--node--content_type_name.tpl.php
when I try calling fields using eg print render($content['field_article_author']);
nothing appears , how else can I call this fields ?
Comments
For this, hide that field
For this, hide that field from content like this:
And use the render() function and the field name to print the field somewhere else:
If it is still not showing anything, try to debug $content array. if you have Devel module enabled you can simply place
dsm($node);
in the template to print out the node object.Also check, Is the field enabled on the manage display tab for the content type?
Thanks,
Preksha
Alternative is $node variable
Alternative is
$node
variable that you can use instead of$content
but in special scenario. In your case first check your Manage Display setting of this content type to make sure this field is not hide from there.Pushpinder Rana #pushpinderdrupal
Acquia Certified Drupal Expert
Hello
Hello
just dosen't work it works well in node--contenttype_name.tpl.php but will not display in page--node--contenttype_name.tpl.php which I prefer using since I can alter the whole template layout as i please
Use correct variable if you
Use correct variable if you are using page template. See Here
you can use here $node object.
Pushpinder Rana #pushpinderdrupal
Acquia Certified Drupal Expert
finally figured it out
finally figured it out
use
Great!
Great!
Please edit your original thread and append [SOLVED] either in start or end of title. It would help other readers to understand the status of this post.
Thanks!
Pushpinder Rana #pushpinderdrupal
Acquia Certified Drupal Expert
finally figured it out
Brilliant. Worked for me too.
How to hide the empty fields with this code?
This code worked successfully using this above said code.
Kindly help me to hide the empty field for above said code.
Only variables should be passed by reference
You should put that in a variable first -
Good Job
@adrianqx: Wowwww!!!Its really worked fine for me..
Dosen't work in Drupal 7.55
It dosen't work in Drupal 7.55
It gets me this error:
Any other solutions?
Almost great
The last solution kind of worked for me. I am using Drupal 7.59
The image shows up but I get an error message: Strict warning : Only variables should be passed by reference
Right, variable only should be passed.
I watched how I did on another site earlier.