Forums / Developer / How to exclude image from Site Map?

How to exclude image from Site Map?

Author Message

Noicokuna Niemoge

Thursday 05 March 2009 3:12:01 am

Hi there;

In eZ Publish 4.0.2, I want to exclude images from sitemap. How can I do this?

Thanks in advance :)

Shiki soku ze ku...

justin kazadi

Thursday 05 March 2009 3:37:07 am

Hi Noicokuna Niemoge,
i think you must override the sitemap template (by creating an other template) or replace the code in stemap template by this code:


<div id='sitemap'>
{let page_limit=10
     col_count=2
     children=fetch('content','list',hash(parent_node_id,$node.node_id,limit,
                                                     $page_limit,offset,$view_parameters.offset,
                                                    class_filter_type,exclude,
                                                    class_filter_array,array( 'class_id_of_your_  image_class' )
))
     child_count=fetch('content','list_count',hash(parent_node_id,$node.node_id))}

<h1>{"Site map"|i18n("design/standard/node/view")} {$node.name|wash}</h1>

<ul>
{section name=Child loop=$children}
	<li><a href={$Child:item.url_alias|ezurl}>{$Child:item.name}</a>
		{let sub_children=fetch('content','list',hash(parent_node_id,$Child:item.node_id,limit,
                                                       $page_limit,
		                                       class_filter_type,exclude,
                                                       class_filter_array,array( 'class_id_of_your_image_class' )
))
		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}
	</li>
{/section}
</ul>
{/let}
</div>

the idea is to exclude the image content class in the fetch so add this code in the fetch function:

                                          class_filter_type,exclude,
                                          class_filter_array, array( 'class_id_of_image_class' )
    

i think this can help you.

The theory is when we know everything and nothing works.
The practice is when everything works and nobody knows why.
If the practice and theory are met, nothing works and we do not know why.

Albert Einstein

Jean-Yves Zinsou

Thursday 05 March 2009 3:37:51 am

Set debug mode on, with display of template used.
Find sitemap template used.
Watch the fecth used, and exclude the classes as needed...

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

Noicokuna Niemoge

Thursday 05 March 2009 3:59:06 am

Thanks for help, I'm going to do it right away :)

Shiki soku ze ku...

Noicokuna Niemoge

Thursday 05 March 2009 4:27:27 am

For reference, this code did the trick:
(excluded image from parent folder and image + infobox from children)

Standard ezwebin design,
extension/ezwebin/design/ezwebin/templates/node/view/sitemap.tpl

{def $page_limit=10
     $col_count=2
     $sub_children=0
     $children=fetch('content','list',hash('parent_node_id', $node.node_id,
                                           'limit', $page_limit,
                                           'offset', $view_parameters.offset,
					   'class_filter_type', 'exclude',
                                           'class_filter_array', array( 'image' ),
                                           'sort_by', $node.sort_array))}
<div class="border-box">
<div class="border-tl"><div class="border-tr"><div class="border-tc"></div></div></div>
<div class="border-ml"><div class="border-mr"><div class="border-mc float-break">

<div class="content-view-sitemap">

<div class="attribute-header">
    <h1 class="long">{"Site map"|i18n("design/ezwebin/view/sitemap")} {$node.name|wash}</h1>
</div>

<table width="100%" cellspacing="0" cellpadding="4">
<tr>
{foreach $children as $key => $child}
    <td>
    <h2><a href={$child.url_alias|ezurl}>{$child.name}</a></h2>
    {if $child.class_identifier|eq( 'event_calendar' )}
        {set $sub_children=fetch('content','list',hash( 'parent_node_id', $child.node_id, 
                                                        'limit', $page_limit,
					  		'class_filter_type', 'exclude',
                                        		'class_filter_array', array( 'image', 'infobox' ),
                                                        'sort_by', array( 'attribute', false(), 'event/from_time' ) ) )}
    {else}
        {set $sub_children=fetch('content','list',hash( 'parent_node_id', $child.node_id,
                                                        'limit', $page_limit,
					  		'class_filter_type', 'exclude',
                                        		'class_filter_array', array( 'image', 'infobox' ),
                                                        'sort_by', $child.sort_array))}
    {/if}
    <ul>
    {foreach $sub_children as $sub_child}
    <li><a href={$sub_child.url_alias|ezurl}>{$sub_child.name}</a></li>
    {/foreach}
    </ul>
    </td>
    {if ne( $key|mod($col_count), 0 )}
</tr>
<tr>
    {/if}
{/foreach}
</tr>
</table>

</div>

</div></div></div>
<div class="border-bl"><div class="border-br"><div class="border-bc"></div></div></div>
</div>

Thanks again!

Shiki soku ze ku...

Teru H.

Monday 08 February 2010 9:24:45 pm

In my experience, placing images in a different section like Media, which is setup by default in Webin extension, prevented the image names from showing up in Sitemap. (I use eZ Publish 4.2.0.)

--

Teru

eZ debug

Timing: Jan 30 2025 00:54:45
Script start
Timing: Jan 30 2025 00:54:45
Module start 'content'
Timing: Jan 30 2025 00:54:45
Module end 'content'
Timing: Jan 30 2025 00:54:45
Script end

Main resources:

Total runtime0.1730 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.0055 587.9531180.8281
Module start 'content' 0.00550.0072 768.7813102.0078
Module end 'content' 0.01270.1602 870.7891529.7344
Script end 0.1729  1,400.5234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00321.8421200.0002
Check MTime0.00130.7450200.0001
Mysql Total
Database connection0.00090.515510.0009
Mysqli_queries0.124672.04021410.0009
Looping result0.00100.59891390.0000
Template Total0.159892.410.1598
Template load0.00090.514310.0009
Template processing0.158991.847710.1589
Override
Cache load0.00060.350910.0006
Sytem overhead
Fetch class attribute can translate value0.00050.296010.0005
XML
Image XML parsing0.00030.167010.0003
General
dbfile0.01247.1715200.0006
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