Problem with random function Options
Jasko
Posted: Monday, January 21, 2008 10:53:03 AM
Rank: Devotee

Joined: 12/11/2006
Posts: 47
Hi,

I am currently working on a site, which running in both danish and in english.

I have build the site so it has two tabs. They are named content(da) for danish content and content(uk) for english content.

On the site there is a box, where some random news text is being displayed. Now, then problem is that when I have only created a node for the danish version an empty box is shown on the english page.

The random function is getting the nodes in random order, so that part of the function is working. But I have some trouble figuring out how I tell the function not to select the empty english "entries".

I believe the problem is in the variable speechBobleCount, where I tell the variable to get the nodes which does not match the current node.

My code is shown below.

Code:

<xsl:variable name="speechBobleRoot" select="umbraco.library:GetXmlNodeById('1086')"/>
<xsl:variable name="speechBobleCount" select="count($speechBobleRoot/node[(@id != $currentPage/@id) and (@nodeTypeAlias = 'Speechboble')])"/>

<xsl:variable name="randomNode" select="TheAgency:randomNode($speechBobleCount)" />


If i write the "speechBobleCount" variable like this:

Code:

<xsl:variable name="speechBobleCount" select="count($speechBobleRoot/node[(@id != $currentPage/@id) and (string-length(./data [@alias='teaserContent_uk']) !=0) and (@nodeTypeAlias = 'Speechboble')])"/>


It is only those entries, where there are both a danish and an english text that is beeing displayed.

I am hoping that someone in here can give me some inspiration on how to get this problem solved and that my question is making sense! :-)

/Jan
Jasko
Posted: Thursday, January 24, 2008 10:49:03 AM
Rank: Devotee

Joined: 12/11/2006
Posts: 47
I got the problem solved by writing the variable like this:

Code:

<xsl:variable name="speechBobleCount">
<xsl:if test="$language = 'da' and $searchLanguage = 'da'">
    <xsl:value-of select="count($speechBobleRoot/node[(@id != $currentPage/@id) and (@nodeTypeAlias = 'Speechboble') and string-length(./data [@alias='teaserContent_da']) &gt;0])"/>
</xsl:if>

<xsl:if test="$language = 'uk' or $searchLanguage = 'uk'">
        <xsl:value-of select="count($speechBobleRoot/node[(@id != $currentPage/@id) and (@nodeTypeAlias = 'Speechboble') and string-length(./data [@alias='teaserContent_uk']) &gt;0])"/>
</xsl:if>

</xsl:variable>


Simple as that :)

/Jan
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.