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 items in index page by date?
MikaV
Hi
Background:
I have implemented article/generating index page example from the Interwoven Best Practices: Templating Tutorial for TS 5.x (
http://devnet.interwoven.com/site.fcgi/techlib/att/048599/1073/templating2002.pdf
).
Question:
How to sort index page automatically so that the newest item (link to the news article) is on the top of the list. Any ideas or examples?
Find more posts tagged with
Comments
Migrateduser
I'm guessing that instead of,
<iw_iterate list="dcr.Breaking_Legal_News" var="mor">
<iw_perl>
<![CDATA[
my $story = iwpt_dcr_value('mor.Story');
$path = $wa.$story;
my $cmd = "iwextattr $path";
$rslt = `$cmd`;
$rslt=~ m/(DCR.*)/;
$linkp="$1";
$dcr=$linkp;
$dcr=~s|DCR=/||g;
chomp $dcr;
use TeamSite:
CRparser;
my
@dcr_lines
;
open( DCR,"< $wa/templatedata/News/Article/data/$dcr" );
while (<DCR>)
{
push(
@dcr_lines
, $_);
}
close( DCR );
$dml= join( "",
@dcr_lines
);
my $parser = TeamSite:
CRparser->new();
my $rootnode = $parser->parse($dml);
$byline= $rootnode->value('Byline');
$source= $rootnode->value('Source');
$b_title= $rootnode->value('Blurb_Headline');
$b_text= $rootnode->value('Blurb_Text');
iwpt_output ("\<p\>\<a href\=\"$story\" class=\"headline\">");
iwpt_output ("$b_title\<\/font\>\<\/a\>\<\/font\>\<br\>\<span class\=\"bodycopy\"\>");
iwpt_output ("$b_text\<\/span\>");
iwpt_output ("\<\/span\>\<br\>\<span class\=\"bylinenews\"\>");
iwpt_output ("$byline, $source\<\/span\>\<br\>");
]]>
</iw_perl>
</iw_iterate>
the following code might work.
<iw_perl><![CDATA[
foreach my $mor (reverse iwpt_dcr_list("dcr.Breaking_Legal_News")) {
my $story = iwpt_dcr_value('mor.Story');
$path = $wa.$story;
my $cmd = "iwextattr $path";
$rslt = `$cmd`;
$rslt=~ m/(DCR.*)/;
$linkp="$1";
$dcr=$linkp;
$dcr=~s|DCR=/||g;
chomp $dcr;
use TeamSite:
CRparser;
my
@dcr_lines
;
open( DCR,"< $wa/templatedata/News/Article/data/$dcr" );
while (<DCR>)
{
push(
@dcr_lines
, $_);
}
close( DCR );
$dml= join( "",
@dcr_lines
);
my $parser = TeamSite:
CRparser->new();
my $rootnode = $parser->parse($dml);
$byline= $rootnode->value('Byline');
$source= $rootnode->value('Source');
$b_title= $rootnode->value('Blurb_Headline');
$b_text= $rootnode->value('Blurb_Text');
iwpt_output ("\<p\>\<a href\=\"$story\" class=\"headline\">");
iwpt_output ("$b_title\<\/font\>\<\/a\>\<\/font\>\<br\>\<span class\=\"bodycopy\"\>");
iwpt_output ("$b_text\<\/span\>");
iwpt_output ("\<\/span\>\<br\>\<span class\=\"bylinenews\"\>");
iwpt_output ("$byline, $source\<\/span\>\<br\>");
}
]]>
</iw_perl>
I'm basically iterating the replicant with a foreach loop (and reversing it) than using an iw_iterate. It will either work fine or mess up the parsing. If it works let us know!
Thanks
Adam Stoller
You can do the reverse sorting in the <iw_iterate> tag too - look at the optional attribute 'order' in the on-line documentation (
http://ts-server/iw/help/tst/pt/TeamSite__PT__iw_iterate.html
)
If you need something fancier than just a simple 'reverse' - you can do that too - again see the aforementioned documentation.
--fish
(Interwoven Senior Technical Consultant)