(Answer) (Category) LON-CAPA User Help : (Category) Authoring :
Can I have conditional rendering of HTML?
Yep, you can use the <block condition="(perl expression)"> ... 
</block> construct.

Example: the following document testtable.html will render itself 
differently (i.e., with a different "right side") based on the query
string parameters passed to it. The condition uses the &EXT function
to access query string parameters passed to the html-page.

<html>
<head>
<title>
                           Title of Document Goes Here
</title>
</head>
<body bgcolor="#FFFFFF">
<table>
<tr><td width="50%" bgcolor="#BBBBBB"><h1>Left Side</h1><a href="testtable.html?show=a">Show A</a>
<a href="testtable.html?show=b&color=blue">Show B in blue</a>
bla bla
<a href="testtable.html?show=b&color=red">Show B in red</a>
bla bla bla bla
<a href="testtable.html?show=b">Show B</a>

</td>
<td bgcolor="#BBFFBB">
<h1>Right Side</h1>
<block condition="&EXT('query.show') eq 'a'">
<h2>I am A</h2>
Bla bla ...
</block>
<block condition="&EXT('query.show') eq 'b'">
<block condition="&EXT('query.color') eq 'blue'">
I will be blue!!!
</block>
<block condition="&EXT('query.color') eq 'red'">
I will be red!!!
</block>

<h2>I am B</h2>

Bla bla
</block>

</td>
</tr>
</table>
</body>
</html>
[Append to This Answer]
Previous: (Answer) When I try to construct a new item, all I see is the login screen below the construction bar.
Next: (Answer) Can I make a document link back to me, or elsewhere?
This document is: http://help.loncapa.org/cgi-bin/fom?file=188
[Search] [Appearance] [Show This Answer As Text]
This is a Faq-O-Matic 2.719.
This FAQ administered by the LON-CAPA team at MSU. Submit a help request ticket to contact us.