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)
Regarding iw_iterate...
Leo
Hi,
I am still in the process of creating the HTML an text outputs using my PTs. I am now facing one problem.
<iw_iterate var='SectionParagraphs' list='dcr.SectionParagraphs'>
<iw_iterate var='MainSection' list='dcr.SectionParagraphs.Main Section'>
<iw_if expr="{iw_value name='dcr.SectionParagraphs.Main Section.Header'/}ne ''">
<iw_then>
<iw_if expr="{iw_value name='dcr.SectionParagraphs.Main Section.Image Picture 1'/}ne ''">
</iw_then>
------ Display Image Picture 1 aligned to left----
</iw_then>
<iw_else>
<iw_if expr="{iw_value name='dcr.SectionParagraphs.Main Section.Image Picture 2'/}ne ''">
<iw_then>
---- Display Image Picture 2 aligned at the center----
</iw_then>
<iw_else>
<iw_if expr="{iw_value name='dcr.SectionParagraphs.Main Section.Image Picture 2'/}ne ''">
<iw_then>
------ Display Image Picture 3 aligned to the right----
</iw_then>
</iw_if>
</iw_else>
</iw_if>
</iw_else>
</iw_if>
</iw_then>
</iw_if>
</iw_iterate>
</iw_iterate>
(Ignore if there are any missing/extra tags in the above snippet)
As the Section Paragraphs (SP) can be replicated. Every SP has a MainSection which also can be replicated under SP.
PT is written in such a way that the MainSection will disply only 1 image (either left, center or right aligned)
I can choose my image in every Main Section.
The problem here is, the image selection made for the Section Paragraph-1 is repeated for the rest of the paragraphs.
(For example, If I choose Image 1 in Section Paragraph-1 and Image 2 in Section Paragraph-2, the Section Paragraph-2 still displays only Image 1 even though its empty)
Am I mising out some thing in my logic? During every iteration, do I need to get the current Section Paragraph name or something? If so, how do i get suct details in my PT?
If I have only 1 Section Paragraph, it works fine. The problem here occurs only when I replicate.
Pls advise.
Thanks.
- Leo
Find more posts tagged with
Comments
fjvelasco
Hi
I think that you don't use correctly the "var" attribute. Think always that behind a PT there is a Perl script, ok? So, if you write <iterate> you are writing a "foreach" statement, and a "var" attribute is a "my $SectionParagraphs" and when you nest another <iterate> you are nesting a "foreach" and when you indicates "list" you may base the expression in the previouse "var", so you need to write "SectionParagraphs.Main.Section" instead "dcr.SectionParagraphs.MainSection".
Resuming: the first "list" need "dcr." but the next "list" need to be based in the previous "var", so write "SectionParagraphs". The <iw_value> takes the reference of the <iterate>"var", so use the "var" to extract values.
An <iterate> is for declare a record "var" that contains a instance of your "list" in each loop pass.
Take a look to <iw_perl> at documentation and discover how to do the same thing in Perl more easily.
Espero que te haya servido de ayuda.
Un saludo.
FJ.
Leo
Hi FJ.
Thanks a lot. It worked!!
- Leo
fjvelasco
Me alegro.
FJ.