Custom portfolio field values not displayed

kruisje's picture
kruisje
Wed, 05/06/2015 - 05:30
#1
Custom portfolio field values not displayed

Hi,

I've added two custom fields to the Portfolio content type (as displayed in the image below)

Custom fields in portfolio

In order to view these fields' values on the portfolio page and grid view, I added two lines of code to the file sites/all/themes/md_boom_multi/template/node--portfolio.tpl.php (between the existing fields):

Edit of node--portfolio.tpl.php

When viewing the portfolio page, the values are unfortunately not rendered correctly ; and "select all" reveals that the value (in this case the number 26 is redered as "<div class="field-label">Age: </div>                26" instead of just the value 26 (which is the case for the pre-defined fields ; they are rendered without the superfluous <div class="field-label">...</div>).

Image title

What do I need to do in orde to correctly render this value? I'm sure I just have to add the new fields somewhere to a list of fields that are already recognized by Boom, but I can't seem to find out where...

Could you please point me in the right direction? Any kind of assistance would be greatly appreciated!

Thanks!

-Pieter

phuonght's picture
phuonght
Fri, 05/08/2015 - 06:08

Hi,

<?php print render($content['field_name']); ?>  can not be wrapped by tag <p></p>. That why there will come the error when printing.

You can use only: <?php print render($content['field_name']); ?> 

and in folder "template" you need to create file field--field-name.tpl.php (you can look for more at: https://www.drupal.org/node/1089656).

In that file, you can print html as you want. 

Log in or register to post comments
Have More Idea?

We are here to build your website!

No Universal solution fits all special business requirements. Our experienced team is ready with ideas and state-of-the-art technical solutions to consult the best solution within your budget.