Template operator for the ads codes

Sunday 10 December 2006 9:21:48 am - 3 replies

Hi all,

I am creating a site that has a lot of advertising codes, in different places in the same page and it depends on which section you are in, i have to change the zone id depends on which section you are in, so someone told me to make a custom template operator, is that true and how can i do it if it's the right thing to do, and if not how shall i do it.

Note: the advertising codes is a JavaScript code

Best regards,

Nayef

Member since: 30/11/2006

Postings: 11

0 Thumbs up!

Sunday 10 December 2006 11:18:28 am

While you might be able to do what you describe with a template operator ...

I would instead interject that from the basis of your first post your could instead more quickly write and use a reusable template construct called a 'toolbar' to provide for your ad.tpl functionality!

1. Create a template to contain the logic of your rules based on sections and ad code combinations.

No mater how you implement this functionality within eZ publish you will end up using a template. Which makes templates a quick simple safe place to start when trying to implement custom functionality.

2. Create logic to control the display of your ad based on your custom code combinations.

3. Configure your toolbar to be displayed in your default pagelayout template via ini settings

4. Test

5. Revise template logic

6. Repeat #3 and #4 until all testing is successful

7. Consensus

//kracker
<i>the fountain ...</i>

<b>references ...</b>
<i>
http://ez.no/ezpublish/documentat.../tips_tricks/javascript_in_templates
http://ez.no/ezpublish/documentat...s/accessing_section_id_in_pagelayout
http://ez.no/ezpublish/documentat...ference/data_fetching/section/object
http://ez.no/ezpublish/documentat...ts/toolbars/how_to_customise_toolbar
http://ez.no/ezpublish/documentat...ars/adding_new_tools_to_toolbar_list
http://ez.no/ezpublish/documentat...e_the_toolbar_system_in_the_template
http://ez.no/ezpublish/documentat...oolbars/how_to_manually_edit_toolbar
http://ez.no/doc/ez_publish/techn...ate_functions/visualization/tool_bar
</i>


Modified on Sunday 10 December 2006 11:21:14 am by kracker

Member since: 07/03/2003

Postings: 754

Member since: 2001.07.13 || http://ezpedia.org/


0 Thumbs up!

Sunday 10 December 2006 11:38:15 am

Here is an example of the addition required to add a template.
This example is not directly related to your requirements.

File: '<i>extension/exampledesign/settings/override/toolbar.ini.append.php</i>'

[Toolbar]
AvailableToolBarArray[]=flashheader

[Tool]
AvailableToolArray[]=FlashFile

[Toolbar_flashheader]
Tool[]
Tool[]=FlashFile

[Tool_flashheader_FlashFile_1]
parent_node=2017

File: '<i>extension/exampledesign/design/example/override/templates/full/full_view_home.tpl</i>'

<div id="col_main_7x" >
  {tool_bar name=flashheader view=full}
  <div class="break"></div>
</div>

File: '<i>extension/exampledesign/design/example/templates/toolbar/full/FlashFile.tpl</i>'

 {* //////////////////////////////////////////////////////////////////////////////// *}

 {def $file=fetch( 'content', 'list', hash( 'parent_node_id', $parent_node,
              'sort_by', array( 'priority', false() ),
              'limit', 1,
              'class_filter_type',  'include',
              'class_filter_array', array( 'image','flash' )
               ) )
}

{* $file|attribute(show,1) *}
{*
{foreach $file as $index => $object }
{$index} : {$object.name}<br />
{/foreach}
*}
{*
              'class_filter_array', array( 'image', 'flash' ) x *}
  {* $file|attribute(show,1) *}

{*
,
              'sort_by', array( 'priority', false() ),
              'limit', 1
,
              'class_filter_type',  'include',
              'class_filter_array', array( 'image' )
              'class_filter_array', array( 'image', 'flash' )
*}
  {* //////////////////////////////////////////////////////////////////////////////// *}


 {if $file.0.class_identifier|eq('image')}
  {def $image=$file}
  {attribute_view_gui attribute=$image.0.object.data_map.image image_class=original href="/products/tools/garbage_bags"|ezurl()}
 {/if}
 {else}

  {def $flash_file=$file.0}
    {let attribute=$flash_file.data_map.file}
    <div id="flashheader">
        <object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"
                {section show=$attribute.content.width|gt( 0 )}width="{$attribute.content.width}"{/section} {section show=$attribute.content.height|gt( 0 )}height="{$attribute.content.height}"{/section} id="objectid{$flash_file.object.id}">
        <param name="wmode" value="transparent">
        <param name="movie" value={concat("content/download/",$attribute.contentobject_id,"/",$attribute.content.contentobject_attribute_id,"/",$attribute.content.original_filename)|ezurl} />
        <param name="quality" value="{$attribute.content.quality}" />
        <param name="play" value="{section show=$attribute.content.is_autoplay}true{/section}" />
        <param name="loop" value="{section show=$attribute.content.is_loop}true{/section}" />
        <embed src={concat("content/download/",$attribute.contentobject_id,"/",$attribute.content.contentobject_attribute_id,"/",$attribute.content.original_filename)|ezurl}
               type="application/x-shockwave-flash"
               quality="{$attribute.content.quality}" wmode="transparent" pluginspage="{$attribute.content.pluginspage}"
               {section show=$attribute.content.width|gt( 0 )}width="{$attribute.content.width}"{/section} {section show=$attribute.content.height|gt( 0 )}height="{$attribute.content.height}"{/section} play="{section show=$attribute.content.is_autoplay}true{/section}"
               loop="{section show=$attribute.content.is_loop}true{/section}" name="objectid{$flash_file.object.id}">

        </embed>
        </object>
        </div>
    {/let}

 {/if}

  {* //////////////////////////////////////////////////////////////////////////////// *}

Member since: 07/03/2003

Postings: 754

Member since: 2001.07.13 || http://ezpedia.org/


0 Thumbs up!

Monday 18 December 2006 12:28:30 pm

Thanks a lot for the help now I have a tool_bar up and running.

Regards,

Nayef

Member since: 30/11/2006

Postings: 11

You must be logged in to post messages in this topic.

Powered by eZ Publish® Content Management System. Copyright © 2009 eZ Systems AS (except where otherwise noted). All rights reserved.