Keyword

How to revers Attachments order

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
1 week 2 days ago - 1 week 2 days ago #177170 by Gorast
How to revers Attachments order was created by Gorast
Hello,

this code gives the attachments to an item:
<?php foreach ($this->item->attachments as $attachment): ?>
	<li> 
		<a title="<?php echo K2HelperUtilities::cleanHtml($attachment->titleAttribute); ?>" href="<?php echo $attachment->link; ?>"><?php echo preg_replace('/__(.*?)__/i', '<dataAttachment>${1}</dataAttachment> <i class="fa fa-file-pdf-o"></i>', $attachment->title) ?></a> 
	</li>
<?php endforeach; ?>

How can I revers the list so the last update is at the top of the list?

Tnx,
[email protected]
Last edit: 1 week 2 days ago by Gorast.

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
1 week 2 days ago #177171 by Gorast
Replied by Gorast on topic How to revers Attachments order

Gorast wrote: Hello,

this code gives the attachments to an item:

<?php foreach ($this->item->attachments as $attachment): ?>
	<li> 
		<a title="<?php echo K2HelperUtilities::cleanHtml($attachment->titleAttribute); ?>" href="<?php echo $attachment->link; ?>"><?php echo preg_replace('/__(.*?)__/i', '<dataAttachment>${1}</dataAttachment> <i class="fa fa-file-pdf-o"></i>', $attachment->title) ?></a> 
	</li>
<?php endforeach; ?>

How can I revers the list so the last update is at the top of the list?
Tnx,
[email protected]


Fount a sollution using array_reverse

<?php foreach ( array_reverse ($this->item->attachments) as $attachment): ?>

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

  • Fotis
  • Fotis's Avatar
  • Online
  • Administrator
  • JoomlaWorks Support Team
More
1 week 1 day ago #177182 by Fotis
Replied by Fotis on topic How to revers Attachments order
Great :)

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