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)
Passing Variable to Component template
System
If I have a Master template(topic_list_mct.tpl) that calls a perl variable:
my $spotltThere = iwpt_dcr_value("dcr.topicListDetail.spotlightInfo.spotlightWithLinksDCR");
and I want to use this variable in a compopnent .tpl of this master. Then how would I do it? This is the way the component .tpl is called from the master .tpl
<iw_perl>
# Getting the list of link DCR and TPL values from the Master List of Links DCR
my $listoflinksTplPath=iwpt_dcr_value('dcr.topicListDetail.listOfLinksTPL');
my $listoflinksDcrPath=iwpt_dcr_value('dcr.topicListDetail.listOfLinksDCR');
# Appending Base Path to the Spotlight DCR and TPL files.
$listoflinksDcrPath = $basePath.$listoflinksDcrPath;
$listoflinksTplPath= $basePath.$listoflinksTplPath;
# Getting the HTML Output of the List Of Links
my $listoflinksHTML = NewCo::NewCo_Generation::getTPLOutput($listoflinksDcrPath,$listoflinksTplPath);
</iw_perl>
<iw_value name="$listoflinksHTML"/>
I want to do a conditional thing in my one component based on whether another component is loaded/exists. I have seen some examples with $iw_arg and & $iw_param but always wrapped inbetween the <iw_clude> tags which isn't the way the component .tpl is being included in the master templates! See attached 2 templates. Any help would be useful!
-Thanks!
P.S. I've attached the two .tpl files involved ( into one sample file clearly separated). I want to be able to read the $spotitthere var from the master .tpl (topic_list_mct.tpl) in the component .tpl (list_of links.tpl)
Find more posts tagged with
Comments
Migrateduser
I don't think the file attaced so here it is:
gzevin
I believe the only way to pass the variable to a component template is to use the appropriate API, that is to invoke your component template accordingly.
If you are using your own methods, the it's up to you how to pass variables properly...
Greg Zevin
Independent Interwoven Consultant/Architect
Sydney, AU
james1
Yes, the normal way of invoking a nested PT is via <iw_include>, as you seem to have already read up on. As you seem to have already know, there is a built-in facility for passing arbitrary data from the parent PT to the child PT. Is there a reason why you are not using the built-in facilities for component templates?
-- James
--
James H Koh
Interwoven Engineering
Migrateduser
The reason is I just had this whole thing dropped on my lap. I had no input into any development of the current environment. Iif you notice that the components are included as static HTML.
<iw_perl>
# Getting the list of link DCR and TPL values from the Master List of Links DCR
my $listoflinksTplPath=iwpt_dcr_value('dcr.topicListDetail.listOfLinksTPL');
my $listoflinksDcrPath=iwpt_dcr_value('dcr.topicListDetail.listOfLinksDCR');
# Appending Base Path to the Spotlight DCR and TPL files.
$listoflinksDcrPath = $basePath.$listoflinksDcrPath;
$listoflinksTplPath= $basePath.$listoflinksTplPath;
# Getting the HTML Output of the List Of Links
my $listoflinksHTML = NewCo::NewCo_Generation::getTPLOutput($listoflinksDcrPath,$listoflinksTplPath);
</iw_perl>
<iw_value name="$listoflinksHTML"/><![CDATA[
So I think my only choice is to, from the component .tpl, to check whether the other component exists or not and then perform internal logic based on that! Or I can go back to square one and re-write everything! Any input???