Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Sorting interates
System
Is there a way to sort iterate results by a specific field within a TPL?
<iw_iterate list='dcr.Resources.Section' var='list' order='list.title'> (this doesnt work - Im trying to sort by title).
Find more posts tagged with
Comments
jbonifaci
First of all, this is the wrong forum for this. Normally you would make this post in the TeamSite FormsPublisher (Templating) Forum.
That aside, the short answer is no, you can't do it in an iw_iterate. The long answer is, you can use perl within an iw_perl to read the entire replicant into an array or an array of hashes and then sort the array yourself before outputting the text.
~Jeff
Adam Stoller
It's usually easier (or perhaps only possible) to do this by breaking out into an <iw_perl> block and using the Perl routines for retrieving the list of replicant items.
Personally, I prefer to write my entire PT with an <iw_perl> block because I find it much simpler and more flexible - but I'm definitely biased in that regard.
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
gzevin
depending on the structure of the replicant, one could *probably* write a custom sort function and then use it in a 'for' loop
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
gzevin
me too. however, there is one case when I prefer to use iw tags - when it comes to branch based on the value of or-replicants
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU
ISCBorisB
You can branch by or-replicant type.
Something like the following:
foreach my $current_replicant (iwpt_dcr_list($or_container_accessor_string)) {
my $current_type = ($current_replicant->get_node_list())[0]->type();
branch here by $current_type
}
Of course it's nothing more than personal preference.
gzevin
true, but this is a thing that I think looks clearer for the client, in XML form
.... but again, it;s good to know all the options
Greg Zevin, Ph.D. Comp. Sc.
Independent Interwoven Consultant/Architect
Sydney, AU