Relation field in category workaround?

More
11 years 7 months ago #36428 by victorio404
Is there a chance to have this variable in some of the next releases?
If not, can you please tell me how to check if the item is expired in the template?

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

More
11 years 1 month ago #40899 by binbenik
Hello,

I followed your process:

1. I created a Relation field
2. I used a duplicated template and add my relation field into position renderonly
3. I edited category_items.php in my duplicate template folder and place at appropriate place:
Code:
<?php echo JText::_("RELATED_ITEMS_COUNT").": ". count($item->fields['myrelationfieldname']->value)>0 ? 'it has related items' : 'no related items' ; ?>

Problem, nothing change.
To test, I also try to add only text after title without success.
If I add a field in my duplicate template via the administrator site, it works and I see it on my site but when I change the code, it's like I change the wrong file.

Do you have an idea ?

Frederic

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

More
11 years 1 month ago #40902 by ggppdk
Hello

-- yes, there is a problem with the above code,
the expression always evaluate to true,
due to JText string being always non-empty

... a set of () parenthesis is needed, i have corrected the code above, it must be like this (notice that i added the parenthesis):
Code:
<?php echo JText::_("RELATED_ITEMS_COUNT").": ". (count($item->fields['myrelationfieldname']->value)>0 ? 'it has related items' : 'no related 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...

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

More
11 years 1 month ago #40903 by binbenik
Thanks for your quick reply and for the code.

My problem is when I add code in category_items.php, nothing happens.
I configure my category to use this duplicate template.
When I drag and drop a field under my duplicate template in administrator site, I can see the result on my site.
I also try to add a simple text after title without success.

Seems like category_items.php in the folder of my duplicate template is not used.

Any idea ?

Frederic

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

More
11 years 1 month ago #40906 by ggppdk
Hello

1. either you edited wrong template

2. or you should have edited category_items_html5.php instead of category_items.php because you set to use HTML5 in template parameters ...

3. you placed it in a place that it is not executed
e.g. you have duplicated blog template
which has 2 loop
LEADING items (1 item per row)
and
standard items (2,3,4 items per row)
... and you placed code inside leading loop
but you are only displaying standard items

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
11 years 1 month ago #40907 by binbenik
Super !
It was the 3rd solution.

Many thanks one more time.

Frederic

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

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.513 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