- Posts: 28
COMMUNITY FORUM
Display category image in K2 Content Module
- Robert Peterson
- Topic Author
- Offline
- Junior Member
Less
More
10 years 10 months ago #120586
by Robert Peterson
Display category image in K2 Content Module was created by Robert Peterson
Hi, everyone! I'm using J!3.1.6, and I'd like to add the category image next to each entry in the K2 Content module.
I've tried this code to no avail:
This has to be an easy one, right? Every other K2 element is in there. All I need to do is yoink the category image associated with each item.
Thanks!!!!!
I've tried this code to no avail:
<?php echo $item->category->image; ?>
This has to be an easy one, right? Every other K2 element is in there. All I need to do is yoink the category image associated with each item.
Thanks!!!!!
Please Log in or Create an account to join the conversation.
- Yiota
- Visitor
10 years 10 months ago #120587
by Yiota
Replied by Yiota on topic Re: Display category image in K2 Content Module
I'm afraid that you cannot fetch the category image through the K2 content module without having to make modifications up to the extend of database queries to the core files.
Please Log in or Create an account to join the conversation.
- Robert Peterson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 28
10 years 10 months ago #120588
by Robert Peterson
Rats! OK, how about this:
Can the module sustain some basic logic related to the category? I'm thinking of something like this:
Is something like that possible?
Thanks!!!
Replied by Robert Peterson on topic Re: Display category image in K2 Content Module
Yiota Ziaggou wrote: I'm afraid that you cannot fetch the category image through the K2 content module without having to make modifications up to the extend of database queries to the core files.
Rats! OK, how about this:
Can the module sustain some basic logic related to the category? I'm thinking of something like this:
if category = 'Booga' {
// do something
} elseif category = 'Zooga' {
// do something
} else {
// do something
} endif
Is something like that possible?
Thanks!!!
Please Log in or Create an account to join the conversation.
- Yiota
- Visitor
10 years 10 months ago #120589
by Yiota
Replied by Yiota on topic Re: Display category image in K2 Content Module
Yes you can do something like that in the module. Just use $item->categoryname for your category variable.
Please Log in or Create an account to join the conversation.
- Robert Peterson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 28
10 years 10 months ago #120590
by Robert Peterson
Yiota, thanks so much for the help! I've tried the following code, but it's throwing a syntax error. Sorry -- I must be missing something obvious.
Any ideas?
Thank you again!!!
b
Replied by Robert Peterson on topic Re: Display category image in K2 Content Module
Yiota Ziaggou wrote: Yes you can do something like that in the module. Just use $item->categoryname for your category variable.
Yiota, thanks so much for the help! I've tried the following code, but it's throwing a syntax error. Sorry -- I must be missing something obvious.
<?php if $item->categoryname == 'AAA' {
echo 'AAA is the Category'
} elseif $item->categoryname == 'BBB' {
echo 'BBB is the Category'
} elseif $item->categoryname == 'CCC' {
echo 'CCC is the category'
} endif; ?>
Any ideas?
Thank you again!!!
b
Please Log in or Create an account to join the conversation.
- Robert Peterson
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 28
10 years 10 months ago #120591
by Robert Peterson
Replied by Robert Peterson on topic Re: Display category image in K2 Content Module
Wait -- I may have it figured out:
<?php if ( $item->categoryname == "AAA" ) {
echo 'AAA is the Category';
} elseif ( $item->categoryname == "BBB" ) {
echo 'BBB is the Category';
} elseif ( $item->categoryname == "CCC" ) {
echo 'CCC is the category';
} ?>
Please Log in or Create an account to join the conversation.
- Yiota
- Visitor
10 years 10 months ago #120592
by Yiota
Replied by Yiota on topic Re: Display category image in K2 Content Module
Yes, this should work in your module code.
Please Log in or Create an account to join the conversation.