views:

495

answers:

2

Hi there

I have a questing about XSLT.

I am making a website on Sitecore CMS, and some of the pages have to show a list of articles. That's not a problem.

Every articlelist can be 'tagged' with one or more tags, and the same for every article. Let's say that I have an articlelist that have been tagged with 'Wordpress'. Then I only want to show articles who also have been tagged with 'Wordpress' of course. That also all right.

But now my problem: If an articlelist is tagged with more than one tag, and an article is tagged with the same tags, then the article will be shown several times, because my XSLT recognizes the tags more than one time.

An example: I have an articlelist with tags 'A' and 'B'. Then I have four articles:

  • Article 1 (Tags: 'A')
  • Article 2 (Tags: 'A' and 'B')
  • Article 3 (Tags: 'B' and 'C')
  • Article 4 (Tags: 'D')

Now in my list I want to show all the articles with the same tags as my articlelist. That will be Article 1, Article 2 and Article 3.

My code does that, but because of the two same tags on the list and Article 2, Article 2 shows up two times, and thats not good.

I have some of my code down below:

<xsl:template match="*">
  <xsl:variable name="ids" select="concat(sc:fld('tags',$sc_currentitem),'|')"/>

  <xsl:call-template name="PrintTitles">
    <xsl:with-param name="ids" select="$ids"/>
    <!-- $sc_currentitem is the item that im currently standing on -->
    <xsl:with-param name="item" select="$sc_currentitem" />
  </xsl:call-template>
</xsl:template>

<xsl:template name="PrintTitles">
  <xsl:param name="ids"/>
  <xsl:param name="item"/>
  <xsl:variable name="itm_id" select="substring-before($ids, '|')"/>

  <xsl:apply-templates select="
    msxml:node-set($item)/item[
      contains(fields/field[@key='tags'], $itm_id)
    ]
  " mode="insure">
    <xsl:with-param name="itm_id" select="$itm_id" />
  </xsl:apply-templates>

  <xsl:call-template name="PrintTitles">
    <xsl:with-param name="ids" select="substring-after($ids, '|')"/>
    <xsl:with-param name="item" select="$item" />
  </xsl:call-template>

</xsl:template>

<xsl:template match="item" mode="insure">
  <xsl:param name="itm_id" />
  <!-- ... -->
</xsl:template>

Heres my XML from one of the articlelists:

<item name="Artikelliste" key="artikelliste" id="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}" tid="{D0C4BD18-E64E-4470-B483-4F33BD50F25F}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="200" language="en" version="1" template="artikelliste" parentid="{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}">
    <fields>
        <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime">
            <content></content>
        </field>
        <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text">
            <content></content>
        </field>
        <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text">
            <content></content>
        </field>
        <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime">
            <content></content>
        </field>
        <field tfid="{72BA1931-236F-4279-8E39-8AC60D33408F}" key="navn i menuen" type="Single-Line Text">
            <content></content>
        </field>
        <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text">
            <content></content>
        </field>
        <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text">
            <content></content>
        </field>
        <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo">
            <content></content>
        </field>
        <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text">
            <content></content>
        </field>
        <field tfid="{9C13A0D7-2B01-4BB6-B35F-9B073ABEDDF3}" key="relaterede sider" type="Treelist">
            <content></content>
        </field>
        <field tfid="{92EB3D7A-DA52-496F-ABC1-6869E3B14551}" key="tags" type="Treelist">
            <content></content>
        </field>
        <field tfid="{2E4FD6E4-83FE-4592-9327-FEC102F817C9}" key="billedetop" type="Image">
            <content></content>
        </field>
        <field tfid="{7C67F2F2-3577-4466-B170-552E463ADD57}" key="source" type="Droptree">
            <content></content>
        </field>
        <field tfid="{C38B9B42-D81D-42ED-A56E-4DBA6FD92D4A}" key="antal artikler" type="Number">
            <content></content>
        </field>
        <field tfid="{5E6D670A-2DD4-4088-8E82-FFD920CEFD9C}" key="alle artikler link" type="Internal Link">
            <content></content>
        </field>
        <field tfid="{BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}" key="__sortorder" type="text">
            <content></content>
        </field>
        <field tfid="{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}" key="__renderings" type="layout">
            <content></content>
        </field>
        <field tfid="{DEC8D2D5-E3CF-48B6-A653-8E69E2716641}" key="__security" type="security">
            <content></content>
        </field>
        <field tfid="{A0CB3965-8884-4C7A-8815-B6B2E5CED162}" key="__editors" type="TreelistEx">
            <content></content>
        </field>
    </fields>
    <item name="HP artikel" key="hp artikel" id="{94A742D5-D446-4170-8AF8-099561F57CC4}" tid="{303D39D0-278E-4034-8420-E19A3DEC3298}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="100" language="en" version="1" template="artikel" parentid="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}">
        <fields>
            <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime">
                <content></content>
            </field>
            <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text">
                <content></content>
            </field>
            <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text">
                <content></content>
            </field>
            <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime">
                <content></content>
            </field>
            <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo">
                <content></content>
            </field>
            <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text">
                <content></content>
            </field>
            <field tfid="{F1F0A054-010A-41F1-B0AC-D0D658727181}" key="teaser" type="Multi-Line Text">
                <content></content>
            </field>
            <field tfid="{476E11CA-A205-48B2-9520-A0C3D954B281}" key="e-mail" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{30A47651-E207-4042-95CC-67C00696EA6F}" key="skrevet af" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{12DE369B-E308-4F24-A617-CD426CF0A29A}" key="relateret information" type="Treelist">
                <content></content>
            </field>
            <field tfid="{311C5D67-66FB-422A-84CC-3312EF8A6B64}" key="medarbejder" type="Multilist">
                <content></content>
            </field>
            <field tfid="{08D9129F-0967-4718-A158-2B8CC322D1E7}" key="tags" type="Treelist">
                <content></content>
            </field>
            <field tfid="{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}" key="__renderings" type="layout">
                <content></content>
            </field>
        </fields>
    </item>
    <item name="Microsoft artikel" key="microsoft artikel" id="{7AF63885-8BA4-4619-9654-12B3865500D0}" tid="{303D39D0-278E-4034-8420-E19A3DEC3298}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="100" language="en" version="1" template="artikel" parentid="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}">
        <fields>
            <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime">
                <content></content>
            </field>
            <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text">
                <content></content>
            </field>
            <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text">
                <content></content>
            </field>
            <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime">
                <content></content>
            </field>
            <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo">
                <content></content>
            </field>
            <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text">
                <content></content>
            </field>
            <field tfid="{F1F0A054-010A-41F1-B0AC-D0D658727181}" key="teaser" type="Multi-Line Text">
                <content></content>
            </field>
            <field tfid="{476E11CA-A205-48B2-9520-A0C3D954B281}" key="e-mail" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{30A47651-E207-4042-95CC-67C00696EA6F}" key="skrevet af" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{2E4FD6E4-83FE-4592-9327-FEC102F817C9}" key="billedetop" type="Image">
                <content></content>
            </field>
            <field tfid="{12DE369B-E308-4F24-A617-CD426CF0A29A}" key="relateret information" type="Treelist">
                <content></content>
            </field>
            <field tfid="{311C5D67-66FB-422A-84CC-3312EF8A6B64}" key="medarbejder" type="Multilist">
                <content></content>
            </field>
            <field tfid="{B61C079A-0B97-4CC0-BB9F-22E7B49D57F9}" key="relaterede sider" type="Treelist">
                <content></content>
            </field>
            <field tfid="{08D9129F-0967-4718-A158-2B8CC322D1E7}" key="tags" type="Treelist">
                <content></content>
            </field>
            <field tfid="{F1A1FE9E-A60C-4DDB-A3A0-BB5B29FE732E}" key="__renderings" type="layout">
                <content></content>
            </field>
        </fields>
    </item>
    <item name="New Artikel" key="new artikel" id="{91D6625E-F0C4-43C0-A990-078536C1989C}" tid="{303D39D0-278E-4034-8420-E19A3DEC3298}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="100" language="en" version="2" template="artikel" parentid="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}">
        <fields>
            <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime">
                <content></content>
            </field>
            <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text">
                <content></content>
            </field>
            <field tfid="{5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}" key="__created by" type="text">
                <content></content>
            </field>
            <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime">
                <content></content>
            </field>
            <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text">
                <content></content>
            </field>
            <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{3E431DE1-525E-47A3-B6B0-1CCBEC3A8C98}" key="__workflow state" type="reference">
                <content></content>
            </field>
            <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo">
                <content></content>
            </field>
            <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text">
                <content></content>
            </field>
            <field tfid="{F1F0A054-010A-41F1-B0AC-D0D658727181}" key="teaser" type="Multi-Line Text">
                <content></content>
            </field>
            <field tfid="{C8F93AFE-BFD4-4E8F-9C61-152559854661}" key="__valid from" type="datetime">
                <content></content>
            </field>
            <field tfid="{08D9129F-0967-4718-A158-2B8CC322D1E7}" key="tags" type="Treelist">
                <content></content>
            </field>
            <field tfid="{12DE369B-E308-4F24-A617-CD426CF0A29A}" key="relateret information" type="Treelist">
                <content></content>
            </field>
        </fields>
    </item>
    <item name="NY" key="ny" id="{F54BC47C-8D7D-4017-BA39-31AAFCD92042}" tid="{303D39D0-278E-4034-8420-E19A3DEC3298}" mid="{00000000-0000-0000-0000-000000000000}" sortorder="100" language="en" version="1" template="artikel" parentid="{92BC787F-C935-4EE7-9D41-AEAF67C9CC06}">
        <fields>
            <field tfid="{25BED78C-4957-4165-998A-CA1B52F67497}" key="__created" type="datetime">
                <content></content>
            </field>
            <field tfid="{BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}" key="__updated by" type="text">
                <content></content>
            </field>
            <field tfid="{5DD74568-4D4B-44C1-B513-0AF5F4CDA34F}" key="__created by" type="text">
                <content></content>
            </field>
            <field tfid="{234DC975-40DA-472B-B315-796C0FAA8D53}" key="meta title" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{D9CF14B1-FA16-4BA6-9288-E8A174D4D522}" key="__updated" type="datetime">
                <content></content>
            </field>
            <field tfid="{8CDC337E-A112-42FB-BBB4-4143751E123F}" key="__revision" type="text">
                <content></content>
            </field>
            <field tfid="{9683EB7C-DE18-472D-B058-562573FAE23D}" key="titel" type="Single-Line Text">
                <content></content>
            </field>
            <field tfid="{3E431DE1-525E-47A3-B6B0-1CCBEC3A8C98}" key="__workflow state" type="reference">
                <content></content>
            </field>
            <field tfid="{001DD393-96C5-490B-924A-B0F25CD9EFD8}" key="__lock" type="memo">
                <content></content>
            </field>
            <field tfid="{08D9129F-0967-4718-A158-2B8CC322D1E7}" key="tags" type="Treelist">
                <content></content>
            </field>
            <field tfid="{93871141-7CB3-472E-9A75-6237A3BCC0F6}" key="tekstindhold" type="Rich Text">
                <content></content>
            </field>
            <field tfid="{F1F0A054-010A-41F1-B0AC-D0D658727181}" key="teaser" type="Multi-Line Text">
                <content></content>
            </field>
        </fields>
    </item>
</item>

So my question is: How do i filter out an article if it is already shown in the list, so it doesn't show up more than one time, even though it has more than one tags in common with the lists tags.

And if some of you know how to sort my articles in the lists after date, that would also be great.

I hope that you understand my problem, and some of you would like to help me :)

Thanks

-Kim Andersen

+2  A: 

One naive solution would be to drag along a $done variable and check against that before outputting anything:

<xsl:template name="PrintTitles">
  <xsl:param name="ids"/>
  <xsl:param name="item"/>
  <xsl:param name="done" select="'|'"/>

  <xsl:variable name="itm_id" select="substring-before($ids, '|')"/>

  <xsl:if test="not(contains($done, concat('|', $itm_id, '|'))">
    <xsl:apply-templates select="msxml:node-set($item)/item[contains(fields/field[@key='tags'], $itm_id)]" mode="insure">
      <xsl:with-param name="itm_id" select="$itm_id"></xsl:with-param>                    
    </xsl:apply-templates>
  </xsl:if>

  <xsl:call-template name="PrintTitles">
    <xsl:with-param name="ids" select="substring-after($ids, '|')"/>
    <xsl:with-param name="item" select="$item" />
    <xsl:with-param name="done" select="concat($done, $itm_id, '|')" />
  </xsl:call-template>

</xsl:template>

However, I have a hunch that the whole problem can be solved more elegantly, but without the input XML this is kind of hard.

Tomalak
I'm not at all sure if this works, though. Admittedly I don't know anything about sitecore. Give me some time to read something about it.
Tomalak
A: 

Hi Tomalak and others (?)

Sorry for not responding to this question. I figured it out, and made a totaly different XSLT, but now it works.

If someone is interested, I have put in my code down below. But there's alot of it ;)

<xsl:template match="*">
tekst tekst_smal

-->
    <xsl:variable name="alleArtikler">
        <root>
            <xsl:choose>
                <xsl:when test="$source/@id != '{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}'">
                    <xsl:apply-templates select="$source/descendant-or-self::item[@template = 'article']">
                        <xsl:with-param name="tags" select="$tags" />
                    </xsl:apply-templates>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="$sc_currentitem/descendant-or-self::item[@template = 'article']">
                        <xsl:with-param name="tags" select="$tags" />
                    </xsl:apply-templates>
                </xsl:otherwise>

            </xsl:choose>
        </root>
    </xsl:variable>
    <xsl:variable name="listTags">
        <root>
            <page>
                <xsl:call-template name="getTags">
                    <xsl:with-param name="ids" select="$tags"></xsl:with-param>
                </xsl:call-template>
            </page>
        </root>
    </xsl:variable>

    <xsl:choose>

        <xsl:when test="$hasChilds">
            <xsl:choose>
                <!-- HVIS ARTIKELLISTEN ER TAGGET -->
                <xsl:when test="$tags != ''">
                    <xsl:variable name="showThese">
                        <root>
                            <xsl:for-each select="msxml:node-set($listTags)//tag">
                                <xsl:variable name="pageTagId" select="."></xsl:variable>

                                <xsl:for-each select="msxml:node-set($alleArtikler)/root/artikel[tag = $pageTagId]">
                                    <artikel date="{@date}">
                                        <id>
                                            <xsl:value-of select="@id" />
                                        </id>
                                    </artikel>
                                </xsl:for-each>
                            </xsl:for-each>
                        </root>
                    </xsl:variable>

                    <xsl:variable name="tt" select="msxml:node-set($showThese)" />
                    <xsl:apply-templates select="$tt/root/artikel[not(id=preceding-sibling::artikel/id)]" mode="Presentation">
                        <xsl:sort data-type="text" select="./@date" order="descending"  />
                    </xsl:apply-templates>                                               
                </xsl:when>

                <!-- HVIS ARTIKELLISTEN IKKE ER TAGGET -->    
                <xsl:otherwise>
                    <xsl:variable name="showThese">
                        <root>
                            <xsl:for-each select="msxml:node-set($alleArtikler)/root/artikel">
                                <artikel date="{@date}">
                                    <id>
                                        <xsl:value-of select="@id" />
                                    </id>
                                </artikel>
                            </xsl:for-each>    
                        </root>
                    </xsl:variable>

                    <xsl:variable name="tt" select="msxml:node-set($showThese)" />
                    <xsl:apply-templates select="$tt/root/artikel[not(id=preceding-sibling::artikel/id)]" mode="Presentation">
                        <xsl:sort data-type="text" select="./@date" order="descending"  />
                    </xsl:apply-templates>

                </xsl:otherwise>
            </xsl:choose>

        </xsl:when>
        <xsl:when test="not($hasChilds)">
            <xsl:choose>
                <!-- HVIS ARTIKELLISTEN ER TAGGET -->
                <xsl:when test="$tags != ''">
                    <xsl:variable name="showThese">
                        <root>
                            <xsl:for-each select="msxml:node-set($listTags)//tag">
                                <xsl:variable name="pageTagId" select="."></xsl:variable>

                                <xsl:for-each select="msxml:node-set($alleArtikler)/root/artikel[tag = $pageTagId]">
                                    <artikel date="{@date}">
                                        <id>
                                            <xsl:value-of select="@id" />
                                        </id>
                                    </artikel>
                                </xsl:for-each>
                            </xsl:for-each>
                        </root>
                    </xsl:variable>

                    <xsl:variable name="tt" select="msxml:node-set($showThese)" />
                    <xsl:apply-templates select="$tt/root/artikel[not(id=preceding-sibling::artikel/id)]" mode="Presentation">
                        <xsl:sort data-type="text" select="./@date" order="descending"  />
                    </xsl:apply-templates>
                </xsl:when>

                <!-- HVIS ARTIKELLISTEN IKKE ER TAGGET -->
                <xsl:otherwise>
                    <xsl:variable name="showThese">
                        <root>
                            <xsl:for-each select="msxml:node-set($alleArtikler)/root/artikel">
                                <artikel date="{@date}">
                                    <id>
                                        <xsl:value-of select="@id" />
                                    </id>
                                </artikel>
                            </xsl:for-each>
                        </root>
                    </xsl:variable>

                    <xsl:variable name="tt" select="msxml:node-set($showThese)" />
                    <xsl:apply-templates select="$tt/root/artikel[not(id=preceding-sibling::artikel/id)]" mode="Presentation">
                        <xsl:sort data-type="text" select="./@date" order="descending"  />
                    </xsl:apply-templates>

                </xsl:otherwise>
            </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
            Der findes desværre ingen artikler.
        </xsl:otherwise>
    </xsl:choose>

    <xsl:if test="sc:fld('All Articles link', $sc_currentitem) != ''">
        <!--<xsl:variable name="alleArtiklerLink" select="sc:fld('Alle artikler link', $sc_currentitem)" />-->
        <div>
            <xsl:choose>
                <xsl:when test="sc:fld('Related pages', $sc_currentitem) = ''">
                    <xsl:attribute name="class">alle_bred</xsl:attribute>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:attribute name="class">alle_smal</xsl:attribute>
                </xsl:otherwise>
            </xsl:choose>
            <div class="alle_artikler">
                <!--<a href="{$alleArtiklerLink}">
                    <img src="/frontend/images/alle_artikler_btn.png" alt="Alle artikler" />
                </a>-->
                <sc:link select="$sc_currentitem" field="All Articles link">
                    <img src="/frontend/images/alle_artikler_btn.png" alt="Alle artikler" />
                </sc:link>
            </div>
        </div>
    </xsl:if>

</xsl:template>
<xsl:template match="artikel" mode="Presentation">
    <xsl:variable name="artikel" select="sc:item(./id, .)"></xsl:variable>
    <!-- <xsl:value-of select="sc:fld('titel', $artikel)"></xsl:value-of> -->

    <xsl:if test="position() &lt; $maxAntal">
    <div>

        <xsl:choose>
            <xsl:when test="(sc:fld('Related pages', $sc_currentitem) = '')">
                <xsl:attribute name="class">artikel_bred</xsl:attribute>

                <div class="liste_top"></div>

                <div class="liste_bg">
                    <div class="liste_tekst">
                        <div class="dato">
                            <xsl:value-of select="sc:formatdate(sc:fld('date',$artikel),'dd-MM-yyyy')"/>
                        </div>
                        <h3>
                            <sc:link select="$artikel">
                                <xsl:value-of select="sc:fld('Title',$artikel)" />
                            </sc:link>
                        </h3>

                        <div class="teaser_bred">
                            <xsl:choose>
                                <xsl:when test="sc:fld('teaser',$artikel) != ''">
                                    <xsl:value-of select="sc:fld('teaser',$artikel)" disable-output-escaping="yes" />
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:value-of select="sc:fld('Content',$artikel)" disable-output-escaping="yes" />
                                </xsl:otherwise>
                            </xsl:choose>

                        </div>
                        <div class="read_more">
                            <sc:link select="$artikel">
                                Læs mere >>
                            </sc:link>
                        </div>

                    </div>
                </div>

                <div class="liste_bund"></div>
            </xsl:when>


            <xsl:otherwise>
                <xsl:attribute name="class">artikel_smal</xsl:attribute>
                <div class="liste_smal_top"></div>

                <div class="liste_smal_bg">
                    <div class="liste_smal_tekst">
                        <div class="dato">
                            <xsl:value-of select="sc:formatdate(sc:fld('date',$artikel),'dd-MM-yyyy')"/>
                        </div>
                        <h3>
                            <sc:link select="$artikel">
                                <xsl:value-of select="sc:fld('Title',$artikel)" />
                            </sc:link>
                        </h3>

                        <div class="teaser_smal">
                            <xsl:value-of select="sc:fld('Content',$artikel)" disable-output-escaping="yes" />
                        </div>
                        <div class="read_more">
                            <sc:link select="$artikel">
                                Læs mere >>
                            </sc:link>
                        </div>

                    </div>
                </div>

                <div class="liste_smal_bund"></div>
            </xsl:otherwise>
        </xsl:choose>

    </div>
    </xsl:if>
</xsl:template>
<xsl:template match="item[@template = 'article']">
    <artikel id="{@id}" date="{sc:fld('date', .)}">

        <xsl:variable name="tags" select="./fields/field[@key='tags']"></xsl:variable>
        <xsl:call-template name="getTags">
            <xsl:with-param name="ids" select="$tags"></xsl:with-param>
        </xsl:call-template>

    </artikel>
</xsl:template>

<xsl:template name="getTags">
    <xsl:param name="ids"/>
    <xsl:if test="$ids">
        <xsl:variable name="itm_id" select="substring-before($ids, '|')"/>
        <xsl:if test="$itm_id">
            <tag>
                <xsl:value-of select="$itm_id" />
            </tag>
        </xsl:if>
        <xsl:if test="$itm_id = ''">
            <tag>
                <xsl:value-of select="$ids" />
            </tag>
        </xsl:if>
        <xsl:call-template name="getTags">
            <xsl:with-param name="ids" select="substring-after($ids, '|')"/>
        </xsl:call-template>
    </xsl:if>
</xsl:template>
Kim Andersen