Adding recursive parameters to a macro Options
mlm
Posted: Saturday, November 18, 2006 9:17:06 AM
Rank: Enthusiast

Joined: 10/9/2006
Posts: 14
Is it possible to use recursive parameters in a macro statment.

I konow this can be done with Get_item

Code:

<?UMBRACO_GETITEM field="siteName" recursive="true"/>


But can this be done with a macro also?

Code:

<?UMBRACO_MACRO macroAlias="ShowSiteName" source="[#siteName]"></?UMBRACO_MACRO>


drobar
Posted: Saturday, November 18, 2006 6:29:38 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,696
Location: KY, USA
Recursion is possible in the XSLT or .NET code called by a macro, though the macro itself is not recursive.

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
mlm
Posted: Sunday, November 19, 2006 7:24:24 AM
Rank: Enthusiast

Joined: 10/9/2006
Posts: 14
I want to add a parameter to the macro,
I want to use a value defined in my root node ([#siteName])
I want to do this on all levels.
Can this be done?

mortenbock
Posted: Sunday, November 19, 2006 4:44:09 PM

Rank: Addict

Joined: 7/19/2006
Posts: 789
Location: Århus, Denmark
I think the way it is usually done is by cycling through the parent pages in the XSLT for your macro until a page contains a value for the specific property. It would be nice though if it were possible to do it right away in the macro tag.

Morten Bock - Level 2 certified - MVP 2008/2009 - My danish blog with a few english posts

neehouse
Posted: Sunday, November 19, 2006 7:33:07 PM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,074
Location: Charleston, West Virginia, United States
Michael,

Since you are wanting to use a value from a specific level, you could easily use XPath to get that value.

Code:

<xsl:value-of select="$currentPage/ancestor-or-self::node[@level='1']/data[@alias='siteName']"/>


If you do not know the exact node, you would have to do a modification to let the xslt find the last (closest in level) entry with a value, and process it this way...

Code:


for your data properties...

<xsl:value-of select="$currentPage/ancestor-or-self::node[data[@alias='siteName']!= ''][position()=last()]/data[@alias='siteName']"/>

or for attributes... (title, level, etc)

<xsl:value-of select="$currentPage/ancestor-or-self::node[@nodeName!= ''][position()=last()]/@nodeName"/>



I did not test these, but the logic should be about right. If you have a node that has HTML content, you may wish to use the library's strip HTML to test for content. That way, empty paragraph tags and such wont count as content.

Hope this helps...

Casey

• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
neehouse
Posted: Sunday, November 19, 2006 7:33:55 PM

Rank: Umbracoholic

Joined: 7/20/2006
Posts: 1,074
Location: Charleston, West Virginia, United States
hoping to fix the tags by replying. When will this forum be fixed?

• 2007/2008 MVP • 2008/2009 MVP • Certified • Licensing • Support • Development • Hosting •
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.