Conditional loop in Universal Module

More
10 years 6 months ago #46883 by Tomoe
Hi,
I have to do something a little special : to replace article opening by direct external link on some articles. So, I made a special template and changed the category view with :
Code:
<?php if (isset($item->positions['link'])) : ?> <?php foreach ($item->positions['link'] as $field) : ?> <h2 class="contentheading"><span class="fc_item_title"><?php echo $field->display; ?></h2></span> <?php endforeach; ?> <?php else : ?> <h2 class="contentheading"><span class="fc_item_title"> <a class="fc_item_title" href="<?php echo JRoute::_(FlexicontentHelperRoute::getItemRoute($item->slug, $item->categoryslug)); ?>"><?php echo $item->title; ?> </span></h2> <?php endif; ?>
It works nice, thanks to FlexiContent incredible flexibility. But now, I have to do the same thing for module. Module displays the category, and I've set in Item List: Displaying of Fields & Other item information -- (Used by Some Layouts e.g. news) > Fields parameters to "Yes" and selected the field "weblink". But I'm unable to go further and to insert a conditional loop saying that if there is something in this field, it shows the field and if not, it show the title. Thanks for any help.

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

More
10 years 6 months ago #46884 by ggppdk
Hello

in v2.2.0 you can use this for custom fields configured to be displayed:

(inside the template file)
mod_flexicontent/tmpl/mytemplate.php
Code:
if ( !empty ($item->fields[ 'myfieldname' ]->value) ) { echo 'myfieldname has values:'; print_r($item->fields[ 'myfieldname' ]->value); }
Regards


-- 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.

More
10 years 6 months ago #46885 by Tomoe
V2.2.0 ? I assumed last version of FlexiContent is v2.1.3 r1857 (the one installed on my site, the last one on download section and not even on SVN). Where is this v2.2.0 version ?
Unfortunately, the code you gave doesn't work in v2.1.3 r1857.

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

More
10 years 6 months ago #46886 by ggppdk
Hello

maybe you do not need the raw field values

try:

if (!empty ($item->fields[ 'myfieldname' ]->display) )

or

if (!empty ($item->fields[ 'myfieldname' ]) )


-- 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.

More
10 years 6 months ago #46888 by Tomoe
Thanks ggppdk! Great! For whose who might be interested, code is
Code:
<div class="fc_block" > <div class="fc_inline_block fcitem_title"> <?php if (!empty ($item->fields[ 'weblink' ]->display)) : ?> <?php echo $item->fields[ 'weblink' ]->display; ?> <?php else : ?> [url=<?php echo $item->link; ?>]<?php echo $item->title; ?>[/url] <?php endif; ?> </div> </div>
And, of course, comment (or erase) $display_title and $use_fields.

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

More
10 years 6 months ago #46893 by ggppdk
Hello

see a PM that i have sent you


-- 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.388 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