This question about Issue in browser: Answered
Bad link with INCLUDE Within IF
In case anyone else runs into this...
I have mutiple includes in my Web Left Bar, depending on whether the user is logged in. These work in FW 1.1.9 but one section is breaking in 2.0.1.
In
WebLeftBar, I have this INCLUDE for authenticated users:
%IF{"context authenticated" then='%INCLUDE{"%SHAREDWEB%.WebLeftBarAuth"}%' else="<nop>"}%
In
WebLeftBarAuth, part of the INCLUDEable code is:
%STARTINCLUDE%
<div class="patternLeftBarPersonal">
%INCLUDE{"%USERSWEB%.%WIKINAME%LeftBar"
warn="<ul><li>[[%SCRIPTURLPATH{edit}%/%USERSWEB%/%WIKINAME%LeftBar?templatetopic=%SYSTEMWEB%.WebLeftBarPersonalTemplate&topicparent=%WIKINAME%][%MAKETEXT{"Create personal sidebar"}%]]</li></ul>"
}%</div>
...
...
%STOPINCLUDE%
And my
%WIKINAME%LeftBar topic looks like this:
%STARTINCLUDE%
*My links:*
* [[Main.VickiBrown][%ICON{"home"}% My home page]]
...
%STOPINCLUDE%
In 1.1.9, all of this code works.
WebLeftBar
screenshot in 1.1.9
In the underlying HTML code, the "My Links" code should look like this (and does, in the
WebLeftBarAuth
page content and in the
WebLeftBar
in 1.1.9)
<strong>My links:</strong> <ul>
<li><a href="/foswiki/bin/view/Main/VickiBrown" title="VickiBrown - 08 Jul 2015 - 21:40 - r1.8: Webhome: Users/VickiBrown.WebHome E mail Find Me Online * Email: vlb #64;cfcl.com (personal) * Email: vbrown #64;philtres.com (work related) ..."><span class='foswikiIcon'><img src='/foswiki/pub/System/DocumentGraphics/home.png' width='16' height='16' alt='home' /></span> My home page</a>
</li>
...</ul>
WebLeftBarAuth
(screenshot) in 2.0.1 - note expected results in the content section, but incorrect results after INCLUDEing in the Left Bar
Something is broken in the final include in the
WebLeftBar
in 2.0.1. The HTML source looks like this:
<strong>My links:</strong> <ul>
<li> [[Main.VickiBrown][<span class=
</li></ul>
Note that the first bullet is being partially treated as literal text (the [ [ brackets are not turned into a link, etc...)
--
VickiBrown - 20 Sep 2015
I think something might be going on with the change from double to single quotes in Foswiki 2.0 HTML generation. Foswiki 2.0 implemented a proposal that we standardize on using double-quotes in macros, and single quotes in HTML. The new %ICON macro generates this, but to add flexibility can override to specify the quotes generated.
* %ICON{"pdf" quote="'"}%
* %ICON{"pdf" quote='"'}%
--
GeorgeClark - 21 Sep 2015
If I remove the ICONs from within the links, the left bar shows
<span class=
so the problem isn't with building the HTML links. (Also, why would this fail only after the INCLUDE?)
ALso, changing the quotes doesn't change the behaviour,
If I take the ICONs out completely, the Left bar works as expected (except for being, sadly, boring.
Additional tests show that it's not the INCLUDE that's having a problem,
per se, but the INCLUDE from within an IF:
--
VickiBrown - 21 Sep 2015
Seems to be quote related. Got it working on your test page by sticking with double-quotes in all TML. Somehow the single quote was terminating the string. I'll look more tomorrow.
--
GeorgeClark - 21 Sep 2015
I suspect that it would work if you used this syntax for your home page link:
* [[Main.VickiBrown][<img src='%ICONURLPATH{"home"}%'> My home page]]
This doesn't explain exactly why the syntax you used would work in 1.1.9 but not in 1.2 but I have seen where
%ICON{}%
macro breaks links and when it does, use the alternative approach described above and it works ok.
--
LynnwoodBrown - 28 Oct 2015
Taking a look at your original question again, you might consider this syntax for your IF macro so that the include is not actually rendered until the condition is tested:
%IF{"context authenticated" then='$percntINCLUDE{\"%SHAREDWEB%.WebLeftBarAuth\"}$percnt' else="<nop>"}%
Otherwise, the INCLUDE gets rendered
before the IF macro and may include quotes that break the
then
clause.
--
LynnwoodBrown - 28 Oct 2015