Template operator for the ads codes

Author Message

Nayef Abu Ebaid

Sunday 10 December 2006 12:21:48 am

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

kracker (the)

Sunday 10 December 2006 2: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/documentation/customization/tips_tricks/javascript_in_templates
http://ez.no/ezpublish/documentation/customization/tips_tricks/accessing_section_id_in_pagelayout
http://ez.no/ezpublish/documentation/reference/data_fetching/section/object
http://ez.no/ezpublish/documentation/customization/components/toolbars/how_to_customise_toolbar
http://ez.no/ezpublish/documentation/customization/components/toolbars/adding_new_tools_to_toolbar_list
http://ez.no/ezpublish/documentation/customization/components/toolbars/how_to_use_the_toolbar_system_in_the_template
http://ez.no/ezpublish/documentation/customization/components/toolbars/how_to_manually_edit_toolbar
http://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_functions/visualization/tool_bar
</i>

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

kracker (the)

Sunday 10 December 2006 2: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: 2001.07.13 || http://ezpedia.se7enx.com/

Nayef Abu Ebaid

Monday 18 December 2006 3:28:30 am

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

Regards,

Nayef

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 22:34:19
Script start
Timing: Jan 18 2025 22:34:19
Module start 'layout'
Timing: Jan 18 2025 22:34:19
Module start 'content'
Timing: Jan 18 2025 22:34:21
Module end 'content'
Timing: Jan 18 2025 22:34:21
Script end

Main resources:

Total runtime1.5789 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 589.0469152.6250
Module start 'layout' 0.00730.0039 741.671939.4609
Module start 'content' 0.01121.5663 781.1328583.6172
Module end 'content' 1.57750.0014 1,364.750016.1563
Script end 1.5789  1,380.9063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.2436160.0002
Check MTime0.00140.0917160.0001
Mysql Total
Database connection0.00140.091510.0014
Mysqli_queries1.511495.7217600.0252
Looping result0.00060.0377580.0000
Template Total1.533097.120.7665
Template load0.00290.186820.0015
Template processing1.530096.902520.7650
Template load and register function0.00010.006010.0001
states
state_id_array0.00220.142410.0022
state_identifier_array0.00250.160620.0013
Override
Cache load0.00250.1609490.0001
Sytem overhead
Fetch class attribute can translate value0.00110.069620.0005
Fetch class attribute name0.00120.074560.0002
XML
Image XML parsing0.00130.080120.0006
class_abstraction
Instantiating content class attribute0.00000.000880.0000
General
dbfile0.00110.0698240.0000
String conversion0.00000.000640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 24
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs