Jump to content

Sort order attachments in the front end


twc02

Recommended Posts

Hello,

 

I've modified the product.tpl to show attachments only to registered users. However, I'm looking for a way to show the first attachment without registering.

 

I've found this piece of code.

 

{if $smarty.foreach.attachments.first}

 

However, prestashop in the back office seems to order the attachments by ID.

 

Can anyone point me in the direction where to modify this? How can I sort by order of upload on product level?

Link to comment
Share on other sites

Well the attachment IDs are actually given by order of upload (if i correctly understood what you mean by "order of upload"), in the sense that if i upload attachment a first, it will get ID=1 and then upload attachment b, it will get ID=2.

 

Maybe the "first attachment" you are trying to show guests also has a specific mime type that the other attachmennts don't have? If so you could

{if $attachment.mime == "application/pdf"} or whatever mime type would be correct.

 

Or, even simpler, add a specific word to the extension name you're trying to show everyone then you could

{if $attachment.name|strstr:"[sPECIFIC_WORD]"}

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...