One of my extra fields is an Image field. I want the page to display the image if one is selected, otherwise show nothing. My code works fine:
getk2.org/community/New-to-K2-Ask-here-first/162398-SOLVED-Hide-extra-field-if-empty#168586
, which was resolved by upgrading to 2.6.3. I suspect this solved the initial issue, but not if someone has placed a value in the field and then removed it.
I've tried a few variations of the following code to no avail - I don't think the code is the problem here.
Y
12 years 9 months ago #123641
Hello,
I have tested this in a default joomla 2.5.17 and K2 installation SVN 2.6.8 and didn't get an empty image.
Try to change your code to
<?php if(isset($this->item->extraFields->ListingImage) && !empty($this->item->extraFields->ListingImage->value)) : ?>
I have tested this in a default joomla 2.5.17 and K2 installation SVN 2.6.8 and didn't get an empty image.
Try to change your code to
<?php if(isset($this->item->extraFields->ListingImage) && !empty($this->item->extraFields->ListingImage->value)) : ?>
Topic Author
12 years 9 months ago #123642
Hi Yiota
I tried that code and also tested on Joomla 2.5.17 and K2.6.7 with no luck.
I do have two possible workarounds. One is similar to Steven's in the afore mentioned thread:
I tried that code and also tested on Joomla 2.5.17 and K2.6.7 with no luck.
I do have two possible workarounds. One is similar to Steven's in the afore mentioned thread:
Y
12 years 9 months ago #123643
Have you tried to see this page with the default K2 template and not your override to see if you still get this empty image tag?
Topic Author
12 years 9 months ago #123644
Sorry for delay in responding. I tried it on the default K2 template and it still returns the empty IMG tag.
Y
12 years 9 months ago #123645
Is a link to your page along with access to your backend available so I take a look?
You can sent me access through the contact form here: getk2.org/contact-us
You can sent me access through the contact form here: getk2.org/contact-us
Topic Author
12 years 9 months ago #123646
I've sent the login details via the contact form. I also removed all my workarounds so the code is as basic as possible, currently in category_item.php:
Y
12 years 9 months ago #123647
I saw the empty image. I need you to try updating your Joomla! and K2 versions to the latest (K2 2.6.7 and Joomla! 2.5.17). Then with the ?template=system we will check if the image is then loading.
PS. Don't forget to take a full site backup first.
It is very strange and I have as well tested this in a Joomla! 2.5.17 and K2 2.6.7 and didn't get an empty image.
Have you made any other modifications in core K2 files?
PS. Don't forget to take a full site backup first.
It is very strange and I have as well tested this in a Joomla! 2.5.17 and K2 2.6.7 and didn't get an empty image.
Have you made any other modifications in core K2 files?
Topic Author
12 years 9 months ago #123648
I've updated Joomla to 2.5.17 and K2 to 2.6.7.
I haven't modified any core files, only created a few template overrides.
The only other thing that is related is that earlier on in the build I installed k2fields from jproven.com/k2fields
This was to allow the client to repeat extra fields while editing the item, although I later uninstalled it as it didn't suit my purpose.
I haven't modified any core files, only created a few template overrides.
The only other thing that is related is that earlier on in the build I installed k2fields from jproven.com/k2fields
This was to allow the client to repeat extra fields while editing the item, although I later uninstalled it as it didn't suit my purpose.
Y
12 years 9 months ago #123649
What is the difference between this page:
Your URL/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=10&Itemid=191
and this one:
Your URL/whats-on/2013-12-06-04-39-51/shows/itemlist/filter?moduleId=133&Itemid=191
What extension/plugin do you use in order to fetch the second view? I see that the url is different. It has extra parameters set on it.
Your URL/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=10&Itemid=191
and this one:
Your URL/whats-on/2013-12-06-04-39-51/shows/itemlist/filter?moduleId=133&Itemid=191
What extension/plugin do you use in order to fetch the second view? I see that the url is different. It has extra parameters set on it.
Topic Author
12 years 9 months ago #123650
I'm using K2 Filter (joomcar.net) to allow users to filter the results. Although, I also need the listings ordered by a date extra field, which only happens once the filter is activated.
The first URL is the straight listings, ordered by default ordering.
The second URL is the listings once the filter has been applied, effectively ordering them by the date extra field.
The first URL is the straight listings, ordered by default ordering.
The second URL is the listings once the filter has been applied, effectively ordering them by the date extra field.
Y
12 years 9 months ago #123651
Have you tried to Disable the filter and check the listing with the extra fields alone?
How can you get this view without the filtering enabled, only pure K2 view?
How can you get this view without the filtering enabled, only pure K2 view?
Topic Author
12 years 9 months ago #123652
Good spot - I should have tried that already. When I disable the filter, the images display correctly. There's now a third dropdown on the site linking to the listings without the filter module on the page.
So I'm guessing this is a bug with the filter then?
So I'm guessing this is a bug with the filter then?
Y
12 years 9 months ago #123653
If you are using the filters to view the page the image comes from the extra fields right?
How is it that you see an image when the filters are not used since the actual extra field is empty? Do you have a condition that checks whether or not to use the image extra field depending on the view?
How is it that you see an image when the filters are not used since the actual extra field is empty? Do you have a condition that checks whether or not to use the image extra field depending on the view?
Topic Author
12 years 9 months ago #123654
Currently the code displays the main image, or the alternative image instead if the alternative image field has a value:
12 years 9 months ago #123655
@Tim
Just tested with K2 2.6.8 DEV build and Joomla! 2.5.18 and i had no issues. No template overrides at all. This means that probably you need to check again your code. If you are not sure how to manipulate extra fields you are recommended to use the default code in the templates for rendering. Also ensure that you do have deleted the value completed and you have not left any spaces to the field.
Just tested with K2 2.6.8 DEV build and Joomla! 2.5.18 and i had no issues. No template overrides at all. This means that probably you need to check again your code. If you are not sure how to manipulate extra fields you are recommended to use the default code in the templates for rendering. Also ensure that you do have deleted the value completed and you have not left any spaces to the field.
Topic Author
12 years 9 months ago #123656
Thanks for following up. I think though it's an issue with the filter as the field works fine until the filter is applied. I've left a message with the developers...
Log in or create an account to reply.