Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
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
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