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)
Getting Items from a replicant inside of Perl
hugenbdd
Hello
I'm trying to access a replicant item within a presentation template, inside of the IW_Perl tags. What I'm trying to do is see if there is any values inside of the tags and copy them to a variable. The code below is what I have tried and I just can't seem to get it to work.
foreach my $lists (iwpt_dcr_lsit('dcr.Sublinks.URL'))
{
my $URL = iwpt_dcr_value('lists');
iwpt_output("$URL");
}
This is very similar to what is in the Templating developers guide on page 140, but I can't seem to get it to ouput anything or assign any value to the $URL variable. My Replicant just consists of two Items URL and Name but I only want to get the URL out of the replicant Item. Any help here would be greatly appriciated.
Thanks
Dave
Find more posts tagged with
Comments
james1
> foreach my $lists (iwpt_dcr_lsit('dcr.Sublinks.URL'))
First of all, the function is "iwpt_dcr_list", not "iwpt_dcr_lsit".
Secondly, is "dcr.Sublinks.URL" the replicant item? From the rest of your message, it sounds like "dcr.Sublinks" is. The replicant item should be the node you are iterating over, since it is the only kind of node that has multiple sub-nodes. So, I think what you really want is:
foreach my $lists (iwpt_dcr_list('dcr.Sublinks'))
{
my $URL = iwpt_dcr_value('lists.URL');
iwpt_output("$URL");
}
-- James
--
James H Koh
Interwoven Engineering
Table structure.JPG
hugenbdd
Thanks...
That worked perfect... I just had a hard time of following the book.......
Dave
mmb
James
Could you explain why the $ is dropped in this example on the iwpt_dcr_value call? This one caught us out for a while..
e.g. foreach my
$
lists (iwpt_dcr_list('dcr.Sublinks'))
{
my $URL = iwpt_dcr_value('
lists
.URL');
iwpt_output("$URL");
}
thanks,
- mark
james1
iwpt_dcr_value() wants an "accessor string", such as "dcr.Sublinks" or "lists.URL".
If you give '$lists.URL' (single-quote), then that is not a valid accessor string because '$lists' is not the name of any DCR node.
If you give "$lists.URL" (double-quote), then "$lists" is evaluated by Perl into its value as a string scalar. Since "$lists" is a DCR node (a Perl object), it probably turns into a string like "HASH(0x888a)". So, the accessor string you end up giving is "HASH(0x888a).URL", which also is not a valid accessor string.
"lists.URL" is a valid accessor string because the foreach loop has introduced "lists" as a valid name for a DCR node.
Hope this helps.
-- James
--
James H Koh
Interwoven Engineering
Aryan
This does not seem to work for me.... Have attached my code... Please help...
Aryan
Ok...it was a typo that was troubling me... A spelling mistake... Thanks!
Aryan
I guess one can also go to the element level while iterating with iwpt_dcr_list operator.
For ex:
foreach my $element (iwpt_dcr_list('dcr.container.element')){
iwpt_output(iwpt_dcr_value('$element'));
}
This also seems to work for me.