Use category image inside item view

More
12 years 8 months ago #36725 by mcmurdok
Hello,
how can I use the category image in the item-view?
If no specific item image is assigned to the item I'd like to show the category image instead of the item-image.

Greetings

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

More
12 years 8 months ago #36729 by ggppdk
1. Duplicate a template
2. Edit item.php of your template
if your item.php is a single line then you need to copy-paste some code (just follow the instructions inside item.php)
3. Use some code like this:
Code:
<?php $cid = (int)JRequest::getVar('cid'); $cid = $cid ? $cid : $this->item->catid; $category = JCategories::getInstance('Content')->get($cid); if ($category->getParams()->get('image')):?> <img src="<?php echo $category->getParams()->get('image'); ?>"/> <?php endif; ?>

NOTE: place the above code in an appropriate PHP IF statement to output it only if needed (look to find) when your item image is output


-- 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 review. Thanks!

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

More
12 years 8 months ago #36733 by mcmurdok
Thank you,
this was exactly what I needed. ;)

Greetings

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

More
12 years 8 months ago #36737 by micker
think to post a review on jed ;)

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

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

More
11 years 3 months ago #50494 by danio_d
I'm sorry to dig up an old post. I need the same change, but in the module.
To view recently added articles, I have to add the name of the category and the photo of this category.
The name I have resolved, but the photo does not come out.

I ask for the support :)

thx
dd

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

More
11 years 3 months ago #50495 by ggppdk
Hello

please note, this is for categoty image via parameter, and not image placed inside the description

also for module, did you try using the FLEXIcontent universal content module?

it can
- show recently added articles together with custom fields
- performance wise for large web-sites
- it can show category information too


-- 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 review. Thanks!

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

More
11 years 3 months ago #50496 by danio_d
Hello,

Just as you say. Picture not included in content but via parameter.

Yes, I use the FC module.

But I did not find (do not know) how can I pull photo category in view Item List (not in Category List).

I'm not sure do You know what I mean?

I need to show in module last 3 article from subcategories. Every item have title, category name and category photo.
And I don't now how show this category photo.

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

More
11 years 3 months ago #50497 by ggppdk
Hello

i understand

1. the "categories" field only shows category title,

2. the module will show category information, title, description, image, etc
-- not inside the item list,
-- but above a set of items belonging to same category

and this is inside the "category list: ..." slider (j2.5) / tab (j3)


-- 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 review. Thanks!

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

More
11 years 3 months ago #50508 by danio_d
Yes, I know that. But ...
My module is shown 3 recently added articles to six sub-categories.
The settings you're talking about, do not give me the opportunity to show 3 subcategories with the latest articles. Then show the newest categorie. Maybe I set something wrong?

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

More
11 years 3 months ago #50512 by ggppdk
Hello

yes the use of "category list" is not appropriate in this case

you will need to custom the template file,

e.g. mynews.php

with for example:
Code:
<?php $category = JCategories::getInstance('Content')->get($item->catid); ?> <?php if ($category->getParams()->get('image')):?> <img src="<?php echo $category->getParams()->get('image'); ?>"/> <?php endif; ?>

notice that we use:
$item->catid
instead of:
$this->item->catid

which we used inside the item view

in any case you should use the item variable that is used inside THE ITEM LOOP:

e.g. you will find inside the news
Code:
<?php foreach ($list[$ord]['featured'] as $item) : ?> ... // USE HERE <?php endforeach; ?> <?php foreach ($list[$ord]['standard'] as $item) : ?> ... // USE HERE <?php endforeach; ?>


-- 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 review. Thanks!

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

Moderators: vistamediajoomlacornerggppdk
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
Save