Keyword

Trying to add category image to all articles based on that

  • Chuck Szymaszek
  • Chuck Szymaszek's Avatar Topic Author
  • Offline
  • New Member
More
7 years 2 months ago #164198 by Chuck Szymaszek
I have searched the K2 forums and I see nothing conclusive on how to do two things..

1. Allow the default category image to flow to the article image for the category it is in and do this in both:
  • a. The k2 module
  • b. the k2 component itself

I would like to basically say, if the k article DOES NOT have a image, then use the category image in its place (in both the k2 module AND the k2 component).

Is there anywhere I can get good information on how to do this? I am not a php programmer.. but am adept in programming.. and just need to know the EXACT files that I need to change.. and maybe the line number to which code I need to change


Thanks and frustrated!

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 2 months ago #164205 by Krikor Boghossian
Replied by Krikor Boghossian on topic Trying to add category image to all articles based on that
Hello Chuck,

I can provide guidelines but I cannot provide a solution since this is a task which requires a decent amount of time.
If you are not familiar with Joomla!'s templating then I suggest that you hire a developer.

Depending on the context, the category's image can be retrieved like this:
$this->item->category->image or,
$item->category->image

You need to override the item.php and category_item.php files
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

A similar concept where a placeholder is being used when there is no image:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L90-L99

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Chuck Szymaszek
  • Chuck Szymaszek's Avatar Topic Author
  • Offline
  • New Member
More
7 years 2 months ago #164259 by Chuck Szymaszek
Hi Krikor,

So if I want to do

A similar concept where a placeholder is being used when there is no image:
github.com/kricore/Advanced-templating-with-K2/blob/master/_inc/cheatsheet.php#L90-L99

Which php page is this referring to for the line code replacement?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 2 months ago #164263 by Krikor Boghossian
Replied by Krikor Boghossian on topic Trying to add category image to all articles based on that
The item.php and category_item.php.
Remember to use overrides and keep an eye where $item and $this->item is being used.
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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


Powered by Kunena Forum