How to display fields in a custom template

More
9 years 5 months ago - 9 years 5 months ago #55341 by Bold
I'm trying to create a custom template which has specific field values wrapped in specific divs so I can control CSS on a granular level. So based on the tutorials I used <?php echo $this->fields->display; ?> to call field values:
Code:
<div class="row"> <?php if ($field->label) : ?> <div class="desc-title"> <?php echo $this->fields['ReferralOrgAddress01']->label; ?> </div> <?php endif; ?> <div class="desc-content"> <?php echo $this->fields['ReferralOrgAddress01']->display; ?> </div> </div>

The result is that the fields are displaying multiple times. Can someone help me determine what I'm doing wrong?

Note: I tried attaching/inserting the item.php for reference but I keep getting an error
Last edit: 9 years 5 months ago by Bold. Reason: issue only partially solved

Please Log in or Create an account to join the conversation.

More
9 years 5 months ago - 9 years 5 months ago #55342 by ggppdk
Hello


1. ADD fields to the 'renderonly' position (creates field but does not show it)
2. Use inside your item(_html5).php or category_items(_html5).php

echo $item->fields->display;


Please read more here:
www.flexicontent.org/administrator/index...xicontent&view=items


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 9 years 5 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
9 years 5 months ago - 9 years 5 months ago #55360 by Bold
Okay I tried that : I moved all fields in the template to render only and updated intem_html5.php
Code:
<?php if (isset($item->positions['renderonly'])) : ?> <div class="description group"> <?php foreach ($item->positions['renderonly'] as $field) : ?> <div class="span6"> <div class="row"> <?php if ($field->label) : ?> <div class="desc-title"><?php echo $item->fields['ReferralOrgDepartment01']->label; ?></div> <?php endif; ?> <div class="desc-content"><?php echo $item->fields['ReferralOrgDepartment01']->display; ?></div> </div> etc..
But now the page doesn't display any field values, it is simply blank.

Do I need to include $myfield_html = FlexicontentFields::getFieldDisplay($item, 'fieldname'); somewhere?

Sorry for my confusion, I'm still new at this)
Last edit: 9 years 5 months ago by Bold. Reason: updating progress of problem

Please Log in or Create an account to join the conversation.

More
9 years 5 months ago - 9 years 5 months ago #55362 by ggppdk
Hello

please don't put position 'renderonly',
into the template,
it is meant not to exist in the template,


- the idea is you add a field in the 'renderonly' position, and then you use:
Code:
echo $item->fields['fieldname']->display;
e.g.
Code:
echo $item->fields['mygalleryfield']->display;

by mistake in my previous post i wrongly wrote: $item->fields->display;
which makes no sense since the $item->fields is an array of fields


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...
Last edit: 9 years 5 months ago by ggppdk.

Please Log in or Create an account to join the conversation.

More
9 years 5 months ago #55367 by Bold
Thanks ggppdk,

Should I not invoke any position statement, and remove the following:
Code:
<?php if (isset($item->positions['description'])) : ?> <div class="description group"> <?php foreach ($item->positions['description'] as $field) : ?>

Please Log in or Create an account to join the conversation.

More
9 years 5 months ago #55371 by ggppdk
Hello

you can add any positions you want to the template
xml and php files

i just said the idea of 'renderonly', is the position will not be present in the template


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.387 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline