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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.