- Posts: 24
COMMUNITY FORUM
- Forum
- K2 Community Forum
- English K2 Community
- catItemIsFeatured class not being generated after K2 upgrade
catItemIsFeatured class not being generated after K2 upgrade
- Jennie Dawson
- Topic Author
- Offline
- Junior Member
Less
More
4 years 9 months ago #174815
by Jennie Dawson
catItemIsFeatured class not being generated after K2 upgrade was created by Jennie Dawson
Hi
I ran some upgrades on one of my K2 sites and upgraded Joomla 3.9.14 to 3.9.15 and K2 from 2.9 to 2.10.2.
Afterwards the customer noticed an icon was missing which I'd styled to appear when the item was ticked as featured.
When I checked the output I could see the the catItemIsFeatured class was missing on the li tag. See screenshots showing item in backend and the code on the frontend.
URL is: www.dyfi-cottages.co.uk/
Please help
Many thanks
Jennie
I ran some upgrades on one of my K2 sites and upgraded Joomla 3.9.14 to 3.9.15 and K2 from 2.9 to 2.10.2.
Afterwards the customer noticed an icon was missing which I'd styled to appear when the item was ticked as featured.
When I checked the output I could see the the catItemIsFeatured class was missing on the li tag. See screenshots showing item in backend and the code on the frontend.
URL is: www.dyfi-cottages.co.uk/
Please help
Many thanks
Jennie
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
4 years 9 months ago #174816
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic catItemIsFeatured class not being generated after K2 upgrade
You should not modify K2's core template files but instead use template overrides as described here: getk2.org/documentation/tutorials/templating-with-k2-and-the-concepts-of-sub-templates
So copy the files from K2 as indicated in the URL above and then re-do your edits. After upgrading in the future, the changes will stick.
So copy the files from K2 as indicated in the URL above and then re-do your edits. After upgrading in the future, the changes will stick.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Jennie Dawson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
4 years 9 months ago #174817
by Jennie Dawson
Replied by Jennie Dawson on topic catItemIsFeatured class not being generated after K2 upgrade
Hi Fotis
I haven't modified the core K2 template files, I always override styles from my main template.css file, which always loads after any module css stylesheets.
The problem is that the class is missing from the k2 output in the first place. I don't know why.
If you look at my screenshots, the K2 item "The Lodge, Panteidal" is set as featured, but in the output the <li> tag for this item contains only the class="even" and is missing the class "CatItemIsFeatured".
Hope that makes sense!
Thanks again
Best wishes
Jennie
I haven't modified the core K2 template files, I always override styles from my main template.css file, which always loads after any module css stylesheets.
The problem is that the class is missing from the k2 output in the first place. I don't know why.
If you look at my screenshots, the K2 item "The Lodge, Panteidal" is set as featured, but in the output the <li> tag for this item contains only the class="even" and is missing the class "CatItemIsFeatured".
Hope that makes sense!
Thanks again
Best wishes
Jennie
Please Log in or Create an account to join the conversation.
- Jennie Dawson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
4 years 9 months ago #174819
by Jennie Dawson
Replied by Jennie Dawson on topic catItemIsFeatured class not being generated after K2 upgrade
OK so I have seen a bit of light on this and realised it probably has to do with my HTML overrides.
The whole layout of my page is contingent on styling the k2 extra fields and for this I created overrides for category_item.php in com_k2 and default.php in mod_k2_content. In the overrides I have added a little bit of code to generate the id number for each extra field as follows:
<li class="type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?> field<?php echo $extraField->id; ?>">
I got this solution by googling it and so far have been able to replicate it, but the PHP construction has changed a bit. I have tried to add this in again to the new default.php for the module, but unfortunately it didn't work resulting in a mess. This is the new code I have tried to edit:
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?> field<?php echo $extraField->id; ?> alias<?php echo ucfirst($extraField->alias); ?>">
Are you able to see where I went wrong?
Thanks Fotis, sorry to be a nuisance
Best wishes
Jennie
The whole layout of my page is contingent on styling the k2 extra fields and for this I created overrides for category_item.php in com_k2 and default.php in mod_k2_content. In the overrides I have added a little bit of code to generate the id number for each extra field as follows:
<li class="type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?> field<?php echo $extraField->id; ?>">
I got this solution by googling it and so far have been able to replicate it, but the PHP construction has changed a bit. I have tried to add this in again to the new default.php for the module, but unfortunately it didn't work resulting in a mess. This is the new code I have tried to edit:
<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?> field<?php echo $extraField->id; ?> alias<?php echo ucfirst($extraField->alias); ?>">
Are you able to see where I went wrong?
Thanks Fotis, sorry to be a nuisance
Best wishes
Jennie
Please Log in or Create an account to join the conversation.
- Jennie Dawson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
4 years 9 months ago - 4 years 9 months ago #174820
by Jennie Dawson
Replied by Jennie Dawson on topic catItemIsFeatured class not being generated after K2 upgrade
Oh, I've now managed to fix the override as I spotted what I missed. I needed to remove the labels as well. Though I do see from the new code that I no longer need to do this as your output now contains unique class for each extra field!
However I still don't have the class "CatItemIsFeatured" on the li tag, so I'm back to square 1.
I have looked at the php code for the li tag in both the old and the new default.php in mod_k2_content and it is identical. There is nothing in either of them that generates the class, but clearly it was there before somehow. I also have identical module on client's other site and that has the class on the li tag.
Thanks
Jennie
However I still don't have the class "CatItemIsFeatured" on the li tag, so I'm back to square 1.
I have looked at the php code for the li tag in both the old and the new default.php in mod_k2_content and it is identical. There is nothing in either of them that generates the class, but clearly it was there before somehow. I also have identical module on client's other site and that has the class on the li tag.
Thanks
Jennie
Last edit: 4 years 9 months ago by Jennie Dawson. Reason: further info
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
4 years 9 months ago #174822
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic catItemIsFeatured class not being generated after K2 upgrade
If there was no override for it, you can simply create it now and append whatever customizations you like.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Jennie Dawson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
4 years 9 months ago #174823
by Jennie Dawson
Replied by Jennie Dawson on topic catItemIsFeatured class not being generated after K2 upgrade
Sorry Fotis, I don't understand. I don't think I have written this clearly enough for you. I have possibly confused things talking about the HTML overrides as I thought they might contain out-dated code which was causing a problem. But I have now brought these up to date so it can't be this.
I am using k2 content module to display items on the home page of this site: www.dyfi-cottages.co.uk/
This generates a list of results using <li> tags, unlike the component which uses <div> tags.
Prior to the K2 upgrade, when an item was selected as 'featured' in the backend, the relevant <li> tag contained the class CatItemIsFeatured. And I have added styling to my template that uses this class.
After the upgrade it no longer contains this class. Therefore my styling has no effect. I cannot add a style if the CSS selector is missing from the HTML.
I have tried to copy the code that creates this class from the K2 component category_item.php to the li tag in my HTML override for the module
But just created PHP error, I don't know enough to do this.
Really appreciate any help you are able to give me
Best regards
Jennie
I am using k2 content module to display items on the home page of this site: www.dyfi-cottages.co.uk/
This generates a list of results using <li> tags, unlike the component which uses <div> tags.
Prior to the K2 upgrade, when an item was selected as 'featured' in the backend, the relevant <li> tag contained the class CatItemIsFeatured. And I have added styling to my template that uses this class.
After the upgrade it no longer contains this class. Therefore my styling has no effect. I cannot add a style if the CSS selector is missing from the HTML.
I have tried to copy the code that creates this class from the K2 component category_item.php to the li tag in my HTML override for the module
But just created PHP error, I don't know enough to do this.
Really appreciate any help you are able to give me
Best regards
Jennie
Please Log in or Create an account to join the conversation.
- Jennie Dawson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
4 years 9 months ago #174828
by Jennie Dawson
Replied by Jennie Dawson on topic catItemIsFeatured class not being generated after K2 upgrade
I have fixed this now. I did a search for CatItemIsFeatured in a backup installation and found the code that now seems to have gone missing from the k2 content module template.
In case anyone else is missing this here it is.
In mod_k2_content -> Default -> default.php I changed this line in my HTML overrides:
<li class="<?php echo ($key%2) ? "odd" : "even"; if(count($items)==$key+1) echo ' lastItem'; ?>">
to:
<li class="<?php echo ($key%2) ? "odd" : "even"; if(count($items)==$key+1) echo ' lastItem'; if($item->featured) echo ' catItemIsFeatured' ?>">
Still confused as to how this went missing out of my previous overrides, I must have mixed something up somewhere. Either that or it's been missing a while and my client just didn't notice. Which does happen.
Thanks
Jennie
In case anyone else is missing this here it is.
In mod_k2_content -> Default -> default.php I changed this line in my HTML overrides:
<li class="<?php echo ($key%2) ? "odd" : "even"; if(count($items)==$key+1) echo ' lastItem'; ?>">
to:
<li class="<?php echo ($key%2) ? "odd" : "even"; if(count($items)==$key+1) echo ' lastItem'; if($item->featured) echo ' catItemIsFeatured' ?>">
Still confused as to how this went missing out of my previous overrides, I must have mixed something up somewhere. Either that or it's been missing a while and my client just didn't notice. Which does happen.
Thanks
Jennie
Please Log in or Create an account to join the conversation.
- JoomlaWorks
- Offline
- Admin
Less
More
- Posts: 6218
4 years 9 months ago #174832
by JoomlaWorks
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by JoomlaWorks on topic catItemIsFeatured class not being generated after K2 upgrade
I'm pretty sure this was never in the module's override.
Check the history of the changes in the file: github.com/getk2/k2/commits/master/modules/mod_k2_content/tmpl/Default/default.php
Either way the naming pattern you mention "catItemIsFeatured" is not compatible with the classes used in the override which are prefixed with "moduleItem". If you look at all K2 templates, you'll notice a naming consistency in CSS classes and IDs.
Check the history of the changes in the file: github.com/getk2/k2/commits/master/modules/mod_k2_content/tmpl/Default/default.php
Either way the naming pattern you mention "catItemIsFeatured" is not compatible with the classes used in the override which are prefixed with "moduleItem". If you look at all K2 templates, you'll notice a naming consistency in CSS classes and IDs.
Fotis / JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Jennie Dawson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
4 years 9 months ago #174834
by Jennie Dawson
Replied by Jennie Dawson on topic catItemIsFeatured class not being generated after K2 upgrade
Perhaps it crossed over from the Styleware module I was originally using. I don't have a record of this but I'm not as organised as you programmers!
Thanks for looking
x
Thanks for looking
x
Please Log in or Create an account to join the conversation.
- Forum
- K2 Community Forum
- English K2 Community
- catItemIsFeatured class not being generated after K2 upgrade