tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/16388-import-global-velocity-format-that-then-matches-on-a-local-macroCascade CMS: Discussion 2018-10-18T20:37:26Ztag:help-archives.hannonhill.com,2010-02-09:Comment/359640522015-02-04T21:59:51Z2015-02-09T14:14:21ZImport global Velocity format that then matches on a local macro<div><p>I've got two formats that I'm dealing with. One is a global,
template-wide format and the other is a local, site-specific
format. The site-specific format is what I have mapped to my
default region and it imports the global format and also has a
macro. The global format gets imported perfectly, however at the
end of the global format, I'm calling the macro (
#local_block($content_block) ) that exists in my local format. The
global format doesn't seem to be communicating back to my local
format and rendering the macro ( #macro(local_block $content_block)
) that's on my local format. Any ideas why this would be
happening?</p>
<p>Local format:<br></p>
<pre>
<code>
#import('site://WDG F1 - Velocity/_cms/velocity/default-region-velocity')
#macro(local_block $content_block)
#set ($local_block_path = $_XPathTool.selectSingleNode($content_block, "path"))
#set ($local_block = $_.locateBlock("${local_block_path.value}", $currentPageSiteName))
#format_local_block($local_block)
#end</code>
</pre>
<p>Global Format:<br></p>
<pre>
<code>
#set ($page_layout = $currentPage.getStructuredDataNode("page-layout"))
#set ($page_title = $_XPathTool.selectSingleNode($contentRoot,"//calling-page/system-page/title").value )
#set ($title_location = $page_layout.getChild("page-title-location").textValue)
#set ($page_columns = $page_layout.getChild("columns").textValue)
#set($column_1 = $_XPathTool.selectNodes($contentRoot, '//column-1/row/row-block'))<br> #foreach($row_block in $column_1)
#set ($column_layout = $block.getStructuredDataNode("row/two-column-layout").textValue)
#parse_row($row)
#end
#macro(parse_row $row)
#set ($this_block_path = $_XPathTool.selectSingleNode($row, "path").value)
#set ($row_block = $_.locateBlock("${this_block_path.value}", $currentPageSiteName))
#set ($row_setup = $_XPathTool.selectNodes($row_block, "content/system-data-structure/row"))
#set ($number_of_columns = "")
#set ($number_of_columns = $_XPathTool.selectSingleNode($row_setup,"columns"))
#set ($column_blocks = $_XPathTool.selectNodes($contentRoot,'//column-1/row/row-block/content/system-data-structure/row/column-1/block') )
#if ($number_of_columns.value == 1 or $number_of_columns.value == 2 or $number_of_columns.value == 3)
#if ($number_of_columns.value == 2 or $number_of_columns.value == 3)
#foreach($content_block in $column_blocks)
#set($path = $_XPathTool.selectSingleNode($content_block, "path").value)
#if ($path != "/")
#local_block($content_block)
#end
#end
#end<br>#end</code>
</pre>
<p>Any and all help would be greatly appreciated!</p></div>sbarre5tag:help-archives.hannonhill.com,2010-02-09:Comment/359640522015-02-05T17:10:30Z2015-02-09T14:14:21ZImport global Velocity format that then matches on a local macro<div><p>Hi,</p>
<p>Seems as though your local macro is not yet registered at the
time it is being called.</p>
<p>When you have a moment, try switching the <code>#import</code>
and <code>#macro</code> directives in your local format and let me
know if this changes anything.</p>
<p>Something else you could try, is apply the global format to the
page region and re-factor your global format to import the local
one dynamically using perhaps the selected block's
<code><site></code> value. Something like the following
maybe:</p>
<pre>
<code>#set($path = $_XPathTool.selectSingleNode($content_block, "path").value)
#if ($path != "/")
#set($site = $_XPathTool.selectSingleNode($content_block, "site").value)
#import("${site}/path/to/local-format")
#local_block($content_block)
#end</code>
</pre>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/359640522015-02-06T15:24:21Z2015-02-09T14:14:21ZImport global Velocity format that then matches on a local macro<div><p>Ryan,</p>
<p>I tried doing it both ways and unfortunately it doesn’t
seem to be working.</p>
<p>I tried to use the currentPageSiteName to get the local velocity
since it will always be local to the current page that someone is
on.</p>
<p>This is my code:<br>
#import("<a>site://${currentPageSiteName}/_cms/velocity/local-velocity”</a>)</p>
<p>I get the following error:<br>
An error occurred while rendering asset preview: The requested
asset does not exist: Format #import with path
'<a>site://${currentPageSiteName}/_cms/velocity/local-velocity&#39</a>;
in templateValidation[line 7, column 1].</p>
<p>Saundra Barrett<br>
Senior Web Developer<br>
Emory University, Web Design Group<br>
Office: 404-727-3437<br>
Cell: 404-670-1238</p></div>sbarre5tag:help-archives.hannonhill.com,2010-02-09:Comment/359640522015-02-06T16:15:44Z2015-02-09T14:14:20ZImport global Velocity format that then matches on a local macro<div><p>Actually – it worked! I’m still getting a grip on
what I can pull out of things and where to run my logic – its
a big difference from XSLT.</p>
<p>Thank you so much for your help!</p>
<p>Saundra Barrett<br>
Senior Web Developer<br>
Emory University, Web Design Group<br>
Office: 404-727-3437<br>
Cell: 404-670-1238</p></div>sbarre5tag:help-archives.hannonhill.com,2010-02-09:Comment/359640522015-02-06T16:35:49Z2015-02-09T14:14:20ZImport global Velocity format that then matches on a local macro<div><p>Not a problem at all, Saundra. I am glad to hear you were able
to get the code working.</p>
<p>Velocity is definitely different, but fun to work with.</p>
<p>I'm going to go ahead and close this discussion, please feel
free to comment or reply to re-open if you have any additional
questions.</p>
<p>Have a great day!</p></div>Ryan Griffith