Forums / General / Fetch keyword problem

Fetch keyword problem

Author Message

Stéphane Bullier

Thursday 16 March 2006 6:49:20 am

Hello,

I have a interogation about the keyword fetching.

I have a class "News" with a keyword attribute "artist". I completed this field with the name of artist that has also the title of another class "artist" eq to $node.name.

When I want display the related "News" of an artist, I write :

{def  $related_news=fetch( 'content', 'keyword',
                                                  hash( alphabet, $node.name ) ) }
<ul>
{foreach $related_news as $element}
	<li><a href={$element.link_object.url_alias|ezurl()}>{$element.link_object.name|wash}</a></li>
{/foreach}
</ul>

All the related news are displayed 2 times. I don't understand why ?

Any feedback would be appreciated.
thanks,

Stéphane

Stéphane Bullier

Monday 27 March 2006 11:46:31 am

He everybody,

There is no solution of my question ?

Please any suggestion is welcome.

Thank. Bobo

Stéphane

Betsy Gamrat

Monday 27 March 2006 4:35:58 pm

Bobo,

Have it print out the $node.node_id and the class_id for the returned content. You may have two nodes that match the keyword.

Stéphane Bullier

Wednesday 29 March 2006 12:29:37 am

Hi Betsy Gamrat,

Yes I have. It's the same node_id for the two $element.link_object.name.

Stéphane

Betsy Gamrat

Wednesday 29 March 2006 7:21:38 am

Bobo,

It sounds like a bug to me.

You may be able to use http://ez.no/doc/ez_publish/technical_manual/3_6/reference/template_operators/arrays/unique as a workaround.

Good luck

Stéphane Bullier

Thursday 30 March 2006 11:38:01 pm

Hello Betsy Gamrat,

Thank you for your advice.

Finally, I use another solution with fetch list :

{def $root_node=fetch( 'content', 'node', hash( 'node_id', 59 ) )
	     $actus=fetch( 'content', 'list',
				          hash( 'parent_node_id', 59,
				       		    'sort_by',		  $root_node.sort_array ) )
		 $nbr_actus=fetch( 'content', 'list_count',
				             hash( 'parent_node_id', 59 ) )
		 $counter=0
		 $limit=1 }
				
		{if $actus}
		<h3 class="actu-artiste">{"News' artist"|i18n("design/base")}</h3>
			{while ne($counter, $nbr_actus) sequence $actus as $actu}
				{if eq($actu.data_map.artiste_lie.content.keyword_string|contains( $node.name ), 1)}
					{* Condition permettant de limiter le nombre d'actu à 3 *}
					{if le($limit, 3)}
						<p class="date-related-news">{$actu.data_map.date.data_int|datetime( 'mydate' )}</p>
						<h4 class="title-related-news">{$actu.name|wash()}</h4>
						<div class="deblayage"></div>
						<div class="related-news-content">
							{attribute_view_gui attribute=$actu.object.data_map.photo}
							{attribute_view_gui attribute=$actu.object.data_map.intro_actu}	
							{if eq($actu.data_map.corps_actu.has_content, true)}
								<p><a href={$actu.url_alias|ezurl()}>{"Read more..."|i18n("design/base")}</a></p>
							{/if}
						</div>
						<div class="deblayage"></div>
					{else}
						<p class="other-related-content"><a href={concat('/content/search', '?&amp;SearchText=', $node.name|urlencode, '&amp;SectionID=6')}>{"Other news of this artist"|i18n("design/base")}</a></p>
						{break}
					{/if}
					{set $limit=inc( $limit )}
				{/if}
				{set $counter=inc( $counter )}
			{/while}
		{/if}
		{undef}

and this solution works well.

Stéphane