Keyword

Get Attachment Link in latest_item.php

  • Shabbir Lakdawala
  • Shabbir Lakdawala's Avatar Topic Author
  • Offline
  • New Member
More
7 years 6 months ago #158264 by Shabbir Lakdawala
Get Attachment Link in latest_item.php was created by Shabbir Lakdawala
Can i get Get Attachment Link in latest_item.php?

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
7 years 6 months ago #158280 by Krikor Boghossian
Replied by Krikor Boghossian on topic Get Attachment Link in latest_item.php
Hello,

Unfortunately the attachments are not available in the latest view.
You can 'hack' the extension but you have to be extra careful and always keep a backup.

In the /components/com_k2/models/item.php file locate:
if (($view == 'item' && $item->params->get('itemAttachments')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemAttachments')))

and replace it with
if (($view == 'item' && $item->params->get('itemAttachments')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemAttachments')) || $view == 'latest')

Or just add the || $view == 'latest' part.

This will enable the attachments in the latest_item.php file.
In your overrides - getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates (this is important) - you can add the code that generates the attachments.
<?php if(count($this->item->attachments)): ?>
	  <!-- Item attachments -->
	  <div class="catItemAttachmentsBlock">
		  <span><?php echo JText::_('K2_DOWNLOAD_ATTACHMENTS'); ?></span>
		  <ul class="catItemAttachments">
		    <?php foreach ($this->item->attachments as $attachment): ?>
		    <li>
			    <a title="<?php echo K2HelperUtilities::cleanHtml($attachment->titleAttribute); ?>" href="<?php echo $attachment->link; ?>">
			    	<?php echo $attachment->title ; ?>
			    </a>
			    <?php if($this->item->params->get('catItemAttachmentsCounter')): ?>
			    <span>(<?php echo $attachment->hits; ?> <?php echo ($attachment->hits==1) ? JText::_('K2_DOWNLOAD') : JText::_('K2_DOWNLOADS'); ?>)</span>
			    <?php endif; ?>
		    </li>
		    <?php endforeach; ?>
		  </ul>
	  </div>
	  <?php endif; ?>

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