Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Custom Tag
Millie
Hello
I am creating a custom tag, called <my_link>.
This tag will be used to insert the HTML to create styled-windows (i.e. those created using javascript's window.open method).
In the presentation template I have somthing like:
<iw_iterate var="item" list="dcr.RHS_Banners">
<my_link image="item.Banner" hover="item.Alt_Tag" url="item.Url" target="item.Target"/>
</iw_iterate>
where dcr.RHS_Banners is a container of properties associated with a link.
Within the dcr, the structure is as follows:
...
<container name="RHS_Banners" min="0" max="10" ...>
<item name="Banner">...</item>
<item name="Alt_Tag">...</item>
<item name="Url">...</item>
<item name="Target">...</item>
<container name="New_Window_Properties" ...>
<item name="Toolbar">...</item>
<item name="Scrollbars">...</item>
... etc
</container>
</container>
This information is passed quite correctly to my custom tag code.
The HTML that the custom tag creates will differ depending upon the value of the 'target' attribute.
In this instance, additional information about the window to be launched is found using the dcr path 'item.New_Window_Properties[0].Toolbar' etc.
However, I don't want to have to supply all the properties of the new window as attributes to the new custom tag - since sometimes they won't be appropriate. Rather, I'd like the custom tag to only look for the new window properties when the value of the 'target' attribute is '_blank'. Its only in this instance that there will be 1 instance of the New_Window_Properties container.
How can I do this from within the custom tag code?
I could modify the tpl to something like
<my_link image="item.Banner" hover="item.Alt_Tag" url="item.Url" target="item.Target" link_container="item"/>
where the link_container attribute refers to the current iteration. But I have no idea how to then access the New_Window_Properties container from that.
I've tried reading through the iw_* tag documentation - but I can't see the wood from the trees.
Any ideas, anyone?
Find more posts tagged with
Comments
Millie
I've found a fix - for those interested enough, read on ....
I modified the presentation template to
<iw_iterate var="item" list="dcr.RHS_Banners">
<my_link link_instance="item"/>
</iw_iterate>
Then in my custom tag code, I used
sub start
{
my ($this, $iw_parser, $start_string) =
@_
;
my $linkInstance = $this->get_attrib('link_instance');
$this->emit_perl(<<EOD);
# <my_link>
my \$i = "$linkInstance";
my \$target = iwpt_dcr_value("\$i.Target");
if (\$target eq "_blank")
{
# access children of the current container ..
my \$toolbar = iwpt_dcr_value("\$i.New_Window_Properties[0].Toolbar");
}
elsif ( ....)
{
}
EOD
}
I think the key to it was when accessing the attribute using $this->get_attrib, treat it as a 'value' - not as a 'macro' nor 'perl-name'.
Once this is obtained, then you can still use iwpt_dcr_value to interrogate the rest of the dcr to your hearts content.