Forums / Setup & design / User managed use of template

User managed use of template

Author Message

Etienne Jolivet

Monday 07 April 2008 7:50:39 am

Hi

I use a Folder content class. There are three different ways of displaying the folder (let's say one without the children, one whith the children, and the last one with children and grandchildren).
I want THE EDITOR to be able to chose in which way the folder he is editing should be displayed. Is there a way to do that ? I mean, a better way than :
- creating three different content classes and set up three override conditions
- setting up one override condition and put "if" operators in my template...

Thank you very much for your help !

Etienne

Mark Marsiglio

Monday 07 April 2008 12:51:19 pm

We did this by adding an attribute to the folder class that is a Select, with three choices. 1) Don't Show Children, 2) Show Children, 3) Shown Children and Grandchildren. Then this is our template code for the display of children in full/folder.tpl:

{def  $include_classes=array('section_home', 'folder', 'calendar', 'article','faq_list','feedback_form','file','link')
	$my_children=fetch('content', 'list', hash('parent_node_id', $node.object.main_node_id, 'class_filter_type', 'include', 'class_filter_array', $include_classes, sort_by, $node.sort_array ))
	$kidshowset=$node.data_map.show_children.content.0
	$url_string=''
	$short_text_at=array()}
{if gt($my_children|count, 0)}
<div class='showsubitems'>
{/if}
    {if and(gt($my_children|count, 0), ne($kidshowset,0) )}
	{section var=this_child loop=$my_children}
	{if ne(24, $this_child.object.section_id)}

	   {set url_string=and(is_set($this_child.data_map.link), is_set($this_child.data_map.url), $this_child.data_map.link.data_int)|choose(fetch(content, node, hash(node_id, $this_child.object.main_node_id)).url_alias|ezroot(no),$this_child.data_map.url.content|ezroot(no))
		  short_text_at = first_set($this_child.object.data_map.short_description, $this_child.object.data_map.summary ,$this_child.object.data_map.intro, $this_child.object.data_map.answer, false())}

	   {if gt($kidshowset,1)}

	   {if $short_text_at.has_content}
	   <h2><a href='{$url_string}'>{first_set($this_child.data_map.namelong.content,$this_child.name)|wash}</a></h2>

{/if}
	   
	   {let grand_children=fetch('content', 'list', hash(parent_node_id, $this_child.object.main_node_id, sort_by, $this_child.sort_array, class_filter_type, 'include', 'class_filter_array', $include_classes))}
		<ul class='sectionhomesubitems'>
		{foreach $grand_children as $this_grandchild}
		   {if ne(24, $this_grandchild.object.section_id)}
	     	   {set url_string=and(is_set($this_grandchild.data_map.link), is_set($this_grandchild.data_map.url), $this_grandchild.data_map.link.data_int)|choose($this_grandchild.url_alias|ezroot(no),$this_grandchild.data_map.url.content|ezroot(no))}
		   <li><a href='{$url_string}'>{$this_grandchild.name|wash}</a></li>
		   {delimiter}|{/delimiter}
		   {/if}
		{/foreach}
		</ul>
	   {/let}

	   {else}

	   <h2><a href='{$url_string}'>{$this_child.name|wash}</a></h2>
 	   <div class="divdesc-perm">{attribute_view_gui attribute=$short_text_at}</div>

	   {/if}
	{/if}
	{/section}
    {/if}
{if gt($my_children|count, 0)}
</div>
{/if}
{undef}

--WARNING - I did not clean out some site specific stuff in this code that you might be able to safely remove because it dealt with a specific section override on our site.

http://www.thinkcreative.com
Turning Ideas Into Strategic Solutions

Etienne Jolivet

Tuesday 08 April 2008 5:01:17 am

Thank you for your answer!

I was hoping that maybe eZ offered something to do this with configuration files... Too bad :)

eZ debug

Timing: Jan 18 2025 15:18:07
Script start
Timing: Jan 18 2025 15:18:07
Module start 'content'
Timing: Jan 18 2025 15:18:08
Module end 'content'
Timing: Jan 18 2025 15:18:08
Script end

Main resources:

Total runtime0.1577 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.0084 587.7188180.8359
Module start 'content' 0.00840.0060 768.554797.9922
Module end 'content' 0.01440.1431 866.5469526.5234
Script end 0.1575  1,393.0703 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.3356200.0002
Check MTime0.00130.8311200.0001
Mysql Total
Database connection0.00130.811110.0013
Mysqli_queries0.109669.50271410.0008
Looping result0.00130.82431390.0000
Template Total0.142490.310.1424
Template load0.00090.589210.0009
Template processing0.141589.737610.1415
Override
Cache load0.00060.372810.0006
Sytem overhead
Fetch class attribute can translate value0.00080.502910.0008
XML
Image XML parsing0.00040.233410.0004
General
dbfile0.00251.5792200.0001
String conversion0.00000.005030.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