Keyword

How to display attachment in search result

  • delaunois
  • delaunois's Avatar Topic Author
  • Offline
  • New Member
More
6 years 4 months ago #118839 by delaunois
delaunois created the topic: How to display attachment in search result
Hi,
I m looking for display attachment (pdf) in search result list.
I think to write something in generic.php but i don't hnow what ! ;)
or so I've forgotten parameter in the administrator area ?!

Thanks for helping

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

More
1 week 2 days ago #174766 by Florin Mircea Rusu
Florin Mircea Rusu replied the topic: How to display attachment in search result
Same question for me as well.
In search results, /public_html/components/com_k2/templates/generic.php file, if i add $item->attachments, nothing happens since $item->attachments is empty.
I see in K2 configuration, at Date & search listings there is not mentioned the attachments as an display option. Extra fields and Comments are :)

While i don't mind about missing in k2 configuration I'm wondering where should I look in order to instanciate $item->attachments.

Help please.

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

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
1 week 2 days ago #174785 by Fotis
Fotis replied the topic: How to display attachment in search result
"$item->attachments" is an array, so you need to loop through it.

Start with var_dump($item->attachments); to see what get's output.

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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

More
5 days 14 hours ago - 5 days 14 hours ago #174844 by Florin Mircea Rusu
Florin Mircea Rusu replied the topic: How to display attachment in search result
Hello,
If i try to output the array, I get the "null" value.
What I'm trying to say is that the k2 search result page, rendered by generic.php, does not initialize the attachments variable at all.
If you will be so kind to point me to the right file where the item's variables are initialized for the search result page I will be happy.

As a general observation:
In K2 General Settings, at "Layout view" / "Date & search listings". I have the "Extra fields" as an option to display/not display. But there is no "Attachments" option. I imagine that the attachments where not intended to be displayed in the "Date & search listings" page.
Last edit: 5 days 14 hours ago by Florin Mircea Rusu.

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

More
5 days 13 hours ago - 5 days 9 hours ago #174846 by Florin Mircea Rusu
Florin Mircea Rusu replied the topic: How to display attachment in search result
Founded:
/public_html/components/com_k2/models/item.php line 154
The "attachments" are loaded only if
($item->params->get('itemAttachments') && $view == 'item') ||
($item->params->get('catItemAttachments') && $view == 'itemlist' && ($task == '' || $task == 'category'))

I need to add a simple
|| $view == 'itemlist' && ($task == 'search' || $task == 'date')
since there is no var for $item->params->get('genericItemAttachments')

A stupid question now: Where should I override /public_html/components/com_k2/models/item.php in template's folder in order to keep the functionality at update?
I have found the answer to the override question.

I don't know better than you but my two cents are: If you consider custom fields important enough to be available on search results page, then maybe the attachments should be available to be displayed there as well.
Last edit: 5 days 9 hours ago by Florin Mircea Rusu. Reason: Problem Solved

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

  • Fotis
  • Fotis's Avatar
  • Away
  • Administrator
  • JoomlaWorks Support Team
More
3 days 16 hours ago #174860 by Fotis
Fotis replied the topic: How to display attachment in search result
You can't override the model. But it makes sense to use all available data in the itemlist views, so I'll make sure to change that in K2 v2.10.3 using common options.

Either way I was planning on "normalizing" these options for the generic views.

I'll keep you posted.

If you use & love K2, please take a moment to add your review and rate it
at the Joomla Extensions Directory: extensions.joomla.org/extension/k2/


IMPORTANT: Please search the forum before posting a question!

JoomlaWorks Support Team Member

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


Powered by Kunena Forum