Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-08-14 02:54:45

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

How to sort category display in txp:images gallery?

Using example 2 (with a few added categories for this example) from the txp:images page:

<txp:images category="arachnids, birds, mammals, insects, fish" thumbnail="1" sort="category asc">
  <txp:if_different>
    <h4><txp:image_info type="category_title" /></h4>
  </txp:if_different>
  <txp:thumbnail wraptag="div" />
  <txp:image_info type="w, h" wraptag="div" class="img_dims" break=" x " />
  by <txp:image_info type="author" />
</txp:images>

Can I ‘custom’ sort the order of the categories using the images tag?

For example, using the above, how do I get it to display in this order (or any custom order):

fish, mammals, arachnids, birds, insects

Offline

#2 2012-08-14 05:43:36

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,173
Website GitHub Mastodon Twitter

Re: How to sort category display in txp:images gallery?

if you use the image name as a sorting method you could have something like

<txp:variable name="sorted" value='<txp:images category="arachnids, birds, mammals, insects, fish" thumbnail="1"><txp:image_info type="id"></txp:images>'>
<txp:images id='<txp:variable name="sorted" />' thumbnail="1" sort="name asc">
  <txp:if_different>
    <h4><txp:image_info type="category_title" /></h4>
  </txp:if_different>
  <txp:thumbnail wraptag="div" />
  <txp:image_info type="w, h" wraptag="div" class="img_dims" break=" x " />
  by <txp:image_info type="author" />
</txp:images>

In the name fields you could just add a number so … using your example above 1fish, 2mammals, 3arachnids, 4birds, 5insects

Having written this… why don’t you just add the number in front of your image categories? Your code above should work just by doing that.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2012-08-14 21:59:31

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: How to sort category display in txp:images gallery?

Numbering the cats worked fine Colak – Thanks

Sometimes you forget the simple, obvious solutions :)

Offline

Board footer

Powered by FluxBB