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.

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 20 2025 03:17:28
Script start
Timing: Jan 20 2025 03:17:28
Module start 'layout'
Timing: Jan 20 2025 03:17:28
Module start 'content'
Timing: Jan 20 2025 03:17:29
Module end 'content'
Timing: Jan 20 2025 03:17:29
Script end

Main resources:

Total runtime0.7722 sec
Peak memory usage4,096.0000 KB
Database Queries52

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 589.1484152.6250
Module start 'layout' 0.00690.0041 741.773439.4453
Module start 'content' 0.01100.7585 781.2188429.3672
Module end 'content' 0.76940.0027 1,210.585912.1719
Script end 0.7721  1,222.7578 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.4764160.0002
Check MTime0.00130.1716160.0001
Mysql Total
Database connection0.00110.146410.0011
Mysqli_queries0.729294.4395520.0140
Looping result0.00050.0655500.0000
Template Total0.737395.520.3686
Template load0.00260.341020.0013
Template processing0.734695.141120.3673
Template load and register function0.00020.027210.0002
states
state_id_array0.00110.148810.0011
state_identifier_array0.00130.174320.0007
Override
Cache load0.00210.2658150.0001
Sytem overhead
Fetch class attribute can translate value0.00060.077610.0006
Fetch class attribute name0.00210.268720.0010
XML
Image XML parsing0.00010.013610.0001
class_abstraction
Instantiating content class attribute0.00000.001020.0000
General
dbfile0.00100.1291100.0001
String conversion0.00000.001740.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/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: 8
 Number of unique templates used: 5

Time used to render debug report: 0.0002 secs