Share » Forums » Developer » List of links to related articles (by...

List of links to related articles (by keyword)

List of links to related articles (by keyword)

Monday 19 January 2009 6:44:16 am - 1 reply

Author Message

André R.

Monday 19 January 2009 12:50:55 pm

templates/content/datatype/view/ezkeyword.tpl from a recent project:

<p>{"Keywords used in this article:"|i18n("design/mydesign/keywords")}</p>
{def $keyword_array = $attribute.content.keyword_string|explode(',')
     $keyword_count = 0
     $keyword_string = ''}
{foreach $keyword_array as $keyword}
    {set $keyword_string = $keyword|trim()}
    {set $keyword_count = fetch( 'content', 'keyword_count', hash( 'alphabet', $keyword_string ) )}
    {if $keyword_count|gt( 1 )}
        <a href={concat('content/keyword/', $keyword_string)|ezurl}>{$keyword_string|wash}</a>
    {else}
        <span>{$keyword_string|wash}</span>
    {/if}
{/foreach}
{undef}

With this you can easily set limit using max parameter on foreach, and you can also add classid in url as parameter if you want to filter on that.
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/keyword_count

But look like you want to link directly to the articles that use same keyword, so you should probably look at:
http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/keyword

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu