Forums / Setup & design / Sitemap customization

Sitemap customization

Author Message

Terry Grossman

Sunday 25 July 2004 8:21:51 am

Hey Folks,

I really like the sitemap auto-generated from the content tree, but I have pieces I wished to hide from the users. My solution was to use an override on sitemap.tpl that skips over content whose name begins with a certain character.

I know this is a bit of a hack, and a better approach would be to extend the content class and add a field that specifies visibility, but this way was very easy to do, and anyone familiar with *NIX will be familiar with "hidden" files/folders beginning with "."

I used "-" as the flag for hiding content from sitemap so that it would be obvious in the admin view which areas were not visible to the users.

Unfortunately, in order to hide the "Media Files" folder, (at least in ver 3.4) you have to manually change the entry in ezcontentobject_name since the admin view won't let you modify it.

Following the code there are some notes about a bug I don't understand...

{* SITEMAP override template. This TPL hides content that begins with a special char *}
{let page_limit=10
     col_count=2
     curr_count=0
     children=fetch('content','list',hash(parent_node_id,$node.node_id,limit,$page_limit,offset,$view_parameters.offset))
     child_count=fetch('content','list_count',hash(parent_node_id,$node.node_id))}

<div class="maincontentheader">

<h1>{"MySite Site map"|i18n("design/standard/node/view")} </h1>
</div>

<table width="100%" cellspacing="0" cellpadding="4">
<tr>
{section name=Child loop=$children}

  {* only show items whose name does not begin with a dash *}
  {section show=$Child:item.name|begins_with( "-" )|not }


    {* increment the table content counter *}
    {set curr_count=inc( $curr_count )}

    <td>
    <h2><a href={$Child:item.url_alias|ezurl}>{$Child:item.name}</a></h2>

    {let sub_children=fetch('content','list',hash(parent_node_id,$Child:item.node_id,limit,$page_limit))
         sub_child_count=fetch('content','list_count',hash(parent_node_id,$Child:item.node_id))}

    <ul>
    {section name=SubChild loop=$:sub_children}
    <li><a href={$:item.url_alias|ezurl}>{$:item.name}</a></li>
    {/section}
    </ul>

    {/let}
    </td>

    {* move to the next table row if we've filled up the current one with data*}
    {section show=mod($curr_count, $col_count)|eq(0)}
</tr>
<tr>
    {/section}

  {/section}

{/section}
</tr>
</table>
{/let}

The standard sitemap.tpl uses the "delimiter modulo" construct to determine when to inject a "</tr><tr>" into the HTML to ensure the content gets put into columns correctly. In order to get that to work I introduced a variable curr_count which only gets incremented when a content section is visible. It is this variable which is checked, rather than the current loop iteration, in order to determine when the TR tags should be added. This doesn't work for some reason, and I'm not sure why -- debug code showed that curr_count was never being incremented and always remained 0 throughout all the loops. Suggestions?

Terry

Terry Grossman

Sunday 25 July 2004 8:23:46 am

I probably should have mentioned that because of the bug, this template only produces a single column

T.

eZ debug

Timing: Jan 30 2025 21:27:05
Script start
Timing: Jan 30 2025 21:27:06
Module start 'content'
Timing: Jan 30 2025 21:27:06
Module end 'content'
Timing: Jan 30 2025 21:27:06
Script end

Main resources:

Total runtime0.2118 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 587.9219370.3047
Module start 'content' 0.00740.0169 958.22661,001.4219
Module end 'content' 0.02430.1874 1,959.64843,892.9141
Script end 0.2117  5,852.5625 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00502.3676200.0003
Check MTime0.00150.6922200.0001
Mysql Total
Database connection0.00080.369310.0008
Mysqli_queries0.109651.77511410.0008
Looping result0.00140.64611390.0000
Template Total0.186988.310.1869
Template load0.00100.464810.0010
Template processing0.185987.798710.1859
Override
Cache load0.00070.314510.0007
Sytem overhead
Fetch class attribute can translate value0.00231.068710.0023
XML
Image XML parsing0.00030.132710.0003
General
dbfile0.00632.9729200.0003
String conversion0.00000.002930.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.0001 secs