Keyword

Replace K2 RSS Image with an Extra Field Value

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
7 years 3 months ago - 7 years 3 months ago #159869 by Joe Campbell
I would like to replace the cached K2 image and sized determined by the RSS Feed parameter,
with the value from Extra Field [14] for each respective item in the feed.

I found the file that I need to edit, but do not know what code to use:
/components/com_k2/models/item.php

Target Code:

$item->description .= '<div class="K2FeedImage"><img src="'.JURI::root().'media/k2/items/cache/'.md5('Image'.$item->id).'_'.$params->get('feedImgSize').'.jpg" alt="'.$altText.'" /></div>';

Desired Results:

$item->description .= '<div class="K2FeedImage"><img src="'.JURI::root().EXTRAFIELD[14].'" alt="'.$altText.'" /></div>';


A cut & paste solution would be much appreciated :)
Last edit: 7 years 3 months ago by Joe Campbell.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 3 months ago #159884 by Krikor Boghossian
Replied by Krikor Boghossian on topic Replace K2 RSS Image with an Extra Field Value
Hello Joe,

$item->extra_fields[14]->value; might do the trick.
Let me know if that works, you might also need to enable extrafields for that view.

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

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
7 years 3 months ago #159897 by Joe Campbell
Replied by Joe Campbell on topic Replace K2 RSS Image with an Extra Field Value
It did not work.

How do I enable extra fields for that view?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 3 months ago #159910 by Krikor Boghossian
Replied by Krikor Boghossian on topic Replace K2 RSS Image with an Extra Field Value
I am not on Twitter often so I don't really check any messages and mentions.
If I don't see you Happy New Year Joe!!

Locate:
	function prepareFeedItem(&$item)
	{

		JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
		$params = K2HelperUtilities::getParams('com_k2');
		$limitstart = 0;
		$view = JRequest::getCmd('view');
		// Category
		$category = JTable::getInstance('K2Category', 'Table');
		$category->load($item->catid);
		$item->category = $category;

Add this line:
$item->extra_fields = $this->getItemExtraFields($item->extra_fields, $item);

It should look like:
	function prepareFeedItem(&$item)
	{

		JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
		$params = K2HelperUtilities::getParams('com_k2');
		$limitstart = 0;
		$view = JRequest::getCmd('view');
		// Category
		$category = JTable::getInstance('K2Category', 'Table');
		$category->load($item->catid);
		$item->category = $category;
                $item->extra_fields = $this->getItemExtraFields($item->extra_fields, $item);

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

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
7 years 3 months ago #159916 by Joe Campbell
Replied by Joe Campbell on topic Replace K2 RSS Image with an Extra Field Value
Not working.

Is this correct:

$item->description .= '<div class="K2FeedImage"><img src="'.JURI::root().$item->extra_fields[14]->value.'" alt="'.$altText.'" /></div>';


Where as "14" is the extra field ID

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

  • Joe Campbell
  • Joe Campbell's Avatar Topic Author
  • Offline
  • Platinum Member
More
7 years 3 months ago #159921 by Joe Campbell
Replied by Joe Campbell on topic Replace K2 RSS Image with an Extra Field Value
I was able to get it to work...

$item->description .= '<div class="K2FeedImage"><img src="'.JURI::root().$item->extraFields->FIELDALIAS->value.'" alt="'.$altText.'" /></div>';

Thanks @Krikor

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


Powered by Kunena Forum