- Posts: 157
COMMUNITY FORUM
Extra Field in Item view in cat. listings
- Goble002
- Topic Author
- Offline
- Premium Member
Less
More
7 years 2 months ago #164336
by Goble002
Extra Field in Item view in cat. listings was created by Goble002
Hi,
is it possible to choose which extra field to appear when item is displayed in category listings ?
I'm also using JA K2 Filter, there I can choose which extra field to display in the search results.
is it possible to choose which extra field to appear when item is displayed in category listings ?
I'm also using JA K2 Filter, there I can choose which extra field to display in the search results.
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
7 years 2 months ago - 7 years 2 months ago #164337
by william white
Replied by william white on topic Extra Field in Item view in cat. listings
You can create an override and replace the extra field loop with references to a single extra field
see Krikors cheatsheet github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L90-L99
line 168
You can also get inside the loop and test for the name of an extra field or fields to show only the ones that pass the test
see Krikors cheatsheet github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L90-L99
line 168
You can also get inside the loop and test for the name of an extra field or fields to show only the ones that pass the test
Last edit: 7 years 2 months ago by william white.
Please Log in or Create an account to join the conversation.
- Goble002
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 157
7 years 2 months ago - 7 years 2 months ago #164343
by Goble002
Replied by Goble002 on topic Extra Field in Item view in cat. listings
Hello and many thanks,
I really don't know anything about php (or very little).
I previously had to use override to display numeric values with Thousand separators (commas).
So I changedto
What I just achieved (after 3h) and glad it's working is below. Am sure there's a better way to achieve the same result but anyway.
I really don't know anything about php (or very little).
I previously had to use override to display numeric values with Thousand separators (commas).
So I changed
<?php echo $extraField->value; ?>
<?php if (is_numeric($extraField->value)) {echo number_format($extraField->value);}
else
{echo $extraField->value;}?>
What I just achieved (after 3h) and glad it's working is below. Am sure there's a better way to achieve the same result but anyway.
<?php if (8==($extraField->id)) {echo '<span class="catItemExtraFieldsLabel">' .$extraField->name. '</span>';echo $extraField->value;} ?>
<?php if (7==($extraField->id)) {echo '<span class="catItemExtraFieldsLabel">' .$extraField->name. '</span>';echo number_format($extraField->value);} ?>
<?php if (12==($extraField->id)) {echo '<span class="catItemExtraFieldsLabel">' .$extraField->name. '</span>';echo number_format($extraField->value);} ?>
Last edit: 7 years 2 months ago by Goble002. Reason: Clean up Code
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 2 months ago #164353
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Extra Field in Item view in cat. listings
I would change (8==($extraField->id)) to:
if it doesn't work try with ==
($extraField->id === 8)
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Goble002
- Topic Author
- Offline
- Premium Member
Less
More
- Posts: 157
7 years 2 months ago #164360
by Goble002
Replied by Goble002 on topic Extra Field in Item view in cat. listings
Many thanks Krikor,
However forgot to mention that the IDs of the extrafields that I don't want ton appear here are 16,14,13,10,11,9. So it seems that it won't do the trick, right ? ;-)
However forgot to mention that the IDs of the extrafields that I don't want ton appear here are 16,14,13,10,11,9. So it seems that it won't do the trick, right ? ;-)
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
7 years 2 months ago #164362
by william white
Replied by william white on topic Extra Field in Item view in cat. listings
you can use the php or operator
www.w3schools.com/PhP/showphp.asp?filename=demo_oper_or
more info
stackoverflow.com/questions/4405795/using-and-or-in-if-else-php-statement
www.w3schools.com/PhP/showphp.asp?filename=demo_oper_or
more info
stackoverflow.com/questions/4405795/using-and-or-in-if-else-php-statement
Please Log in or Create an account to join the conversation.