Same page for news (list, show selected, show default)
This is an open discussion with 3 replies, filed under XSLT.
Search
Why the variable $novidade
don't works into for-each
?
I tested a value-of
after the first if
and printed ok.
If you set a variable inside an if, it would only be available inside the if block, meaning that the rest of the stylesheet will still use the previously set variable.
Is $novidade
an url param? If that is the case, the best thing would be to create another variable and set its value to either $novidade
or novidades/entry[1]/titulo/@handle
. Something along these lines:
<xsl:variable name="new-variable"> <xsl:choose> <xsl:when test="$novidade"> <xsl:value-of select="$novidade" /> </xsl:when> <xsl:otherwise> <xsl:value-of select="novidades/entry[1]/titulo/@handle" /> </xsl:otherwise> </xsl:choose> </xsl:variable>
Hi Marco, perfect thank you very much. Sorry about my english =)
I have another problem.
I need test
if $novidade
has value and
if this value match with the titulo/@handle
of one these entries. And get the entry id of this match. To use to write a class='active'
and show the current news. Design is attached to make sense.
<novidades> <section id="5" handle="novidades">Novidades</section> <entry id="157"> <data time="19:42" weekday="4">2012-06-21</data> <titulo handle="teste-3">Teste 3</titulo> <texto mode="formatted"> <p>Teste 3</p> </texto> </entry> <entry id="156"> <data time="19:42" weekday="3">2012-06-20</data> <titulo handle="teste-2">Teste 2</titulo> <texto mode="formatted"> <p>Teste 2</p> </texto> </entry> </novidades>
Create an account or sign in to comment.
I have sabe page for news like
/news
and pass parameter to show selected news/news/title-of-news
.So I'm having difficult with xsl logic maybe.
1) How set something like
news/entry[1]/title/@handle
as default if have null$currentNews
parameter like<currentNews />
?2) How show
news/entry/title/@handle = $currentNews
?Make sense?
The css class for currentNews is ok: http://pastie.org/4130653