Keyword

How to revers Attachments order

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 6 months ago - 3 years 6 months 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,
S@
Last edit: 3 years 6 months ago by Gorast.

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

  • Gorast
  • Gorast's Avatar Topic Author
  • Offline
  • Premium Member
More
3 years 6 months 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,
S@


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.

More
3 years 6 months ago #177182 by JoomlaWorks
Replied by JoomlaWorks on topic How to revers Attachments order
Great :)

Fotis / 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