All pastes #119228 Raw Edit

zrg

public text v1 · immutable
·published 2006-08-06 19:01 UTC
rendered paste body
{*
  Parameters:
  blockname - should be different for each block, used for css
  container_id - container node id of banners
  show_controls - true to show edit-controls for banner block
*}

{** Load path nodes **}
{def $root_node=fetch( 'content', 'node', hash( 'node_id', 2 ) )}
{def $node=fetch( 'content', 'node', hash( 'node_id', $module_result.node_id ) )}
{if not($node)}
    {def $node=$root_node}
{/if}
{def $menu_path=merge($module_result.path, array(hash("url_alias", $node.url_alias)))}
{def $path_node_ids=array()}
{foreach $menu_path as $step}
    {if $step.url_alias}
        {def $step_node=fetch( 'content', 'node', hash( 'node_path', $step.url_alias ) ) }
        {set $path_node_ids=merge($path_node_ids, array($step_node.node_id))}
    {/if}
{/foreach}

{** Print the banners**}
{def $count=1
     $current_user=fetch('user','current_user')
     $container=fetch( content, node, hash( node_id, $container_id ) )
}
<div id="banner-block-{$blockname}">
  {cache-block keys=array($container_id, $node.node_id)}
    {section var=banner loop=fetch(content, list, hash(parent_node_id, $container.node_id, 
                                                       class_filter_type,  include,
                                                       sort_by, $container.sort_array,
                                                       class_filter_array, array( 'banner' )))}
      {def $show_under=$banner.object.data_map.show_under.content.relation_list}
      {def $dont_show_under=$banner.object.data_map.dont_show_under.content.relation_list}
      {def $showit=not($show_under)}
      {foreach $show_under as $show_under_node}
        {if $path_node_ids|contains($show_under_node.node_id)}
          {set $showit=true()}
        {/if}
      {/foreach}
      {foreach $dont_show_under as $dont_show_under_node}
        {if $path_node_ids|contains($dont_show_under_node.node_id)}
          {set $showit=false()}
        {/if}
      {/foreach}
      
      
      {if $showit}
        <div class="banner-{$blockname}-{$count}">
            {if $banner.object.data_map.href.has_content}
              <a href={$banner.object.data_map.href.content|ezurl} target="{attribute_view_gui attribute=$banner.object.data_map.target}">
            {/if}
            {if $banner.object.data_map.xmlcontent.content.output.output_text|trim()}
              {attribute_view_gui attribute=$banner.object.data_map.xmlcontent}
            {else}
              <img src="/{$banner.object.data_map.image.content[original].url}">
            {/if}
            {if $banner.object.data_map.href.has_content}
              </a>
            {/if}
        </div>
      {/if}
      {set $count=inc($count)}
    {/section}
  {/cache-block} 
  
  {section show=and($show_controls, count($container.object.can_create_class_list))}
    <div class="banner-controls">
      <form method="post" action={concat("/content/view/full/", $container.node_id)|ezurl}>
        <input class="button" type="submit" name="EditButton" value="{'Edit'|i18n('design/standard/node/view')}" />
      </form>
    </div>
  {/section}
</div>