Hi I have a presentation template. And there is only one iw_iterate tag inside it.How can I get the total no. of times the iw_iterate element will be run , i.e. how many times the item has been iterated in the dcr?I have to store that count in a variable say 'x'.Then this variable will be used in a javascript code written inside SCRIPT tags in the PT itself.
You can use one of the attributes of tag called iteration. It gives you the number of iteration inside the tag e.g. [HTML] process each valueto get the count[/HTML] which will give you output something like: 1. abc2. defOther way is to use some perl coding inside. Like to get the count of total number of items under a replicant you can use: [HTML] my @list=iwpt_dcr_list('dcr.x.y'); my $count = scalar(@list);[/HTML] I've not tested the code. But It should work with some twisting on your side.
Could you please be a little more explicit ! I didnot understand where to add these lines !
< iw_perl > my @list = iwpt_dcr_list('dcr.x.y'); my $count = scalar(@list);< /iw_perl >< SCRIPT > alert('{iw_value name="$count"/}');< /SCRIPT >
Sorry, the tage disappeared in the post. e.g. you can add following lines: <iw_perl> my @list = iwpt_dcr_list('dcr.x.y'); my $count = scalar(@list);</iw_perl><SCRIPT> alert('{iw_value name="$count"/}');</SCRIPT> PS: Remoe the spaces that I've put in < tags >.
<iw_perl> my @list = iwpt_dcr_list('dcr.x.y'); my $count = scalar(@list);</iw_perl><SCRIPT> alert('{iw_value name="$count"/}');</SCRIPT>
(I removed the spaces for you ;-)Note - you don't need the scalar() piece - the fact that the left hand side is a scalar variable automatically puts @list into scalar context.
Thanks Ghoti. But when I had put the tags without spaces, it got disappeared .