Forums / General / Template operator for the ads codes

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

eZ debug

Timing: Jan 18 2025 19:01:15
Script start
Timing: Jan 18 2025 19:01:15
Module start 'content'
Timing: Jan 18 2025 19:01:15
Module end 'content'
Timing: Jan 18 2025 19:01:16
Script end

Main resources:

Total runtime0.3043 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0079 587.7266180.8359
Module start 'content' 0.00790.0143 768.5625101.9766
Module end 'content' 0.02220.2820 870.5391530.1719
Script end 0.3042  1,400.7109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00371.2194200.0002
Check MTime0.00160.5196200.0001
Mysql Total
Database connection0.00180.579610.0018
Mysqli_queries0.212069.65551410.0015
Looping result0.00180.58661390.0000
Template Total0.281592.510.2815
Template load0.00080.274410.0008
Template processing0.280692.221310.2806
Override
Cache load0.00060.189610.0006
Sytem overhead
Fetch class attribute can translate value0.00100.318810.0010
XML
Image XML parsing0.00030.094310.0003
General
dbfile0.02478.1131200.0012
String conversion0.00000.002730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs