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:
<div class="patternLeftBarPersonal">
      warn="<ul><li>[[%SCRIPTURLPATH{edit}%/%USERSWEB%/%WIKINAME%LeftBar?templatetopic=%SYSTEMWEB%.WebLeftBarPersonalTemplate&topicparent=%WIKINAME%][%MAKETEXT{"Create personal sidebar"}%]]</li></ul>"

And my %WIKINAME%LeftBar topic looks like this:

*My links:*
   * [[Main.VickiBrown][%ICON{"home"}% My home page]]

In 1.1.9, all of this code works.

WebLeftBar screenshot in 1.1.9

SupportQ1671 LeftBar119.png

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; (personal) * Email: vbrown #64; (work related) ..."><span class='foswikiIcon'><img src='/foswiki/pub/System/DocumentGraphics/home.png' width='16' height='16' alt='home' /></span> My home page</a>

WebLeftBarAuth (screenshot) in 2.0.1 - note expected results in the content section, but incorrect results after INCLUDEing in the Left Bar

SupportQ1671 LeftBarAuth.png

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][&lt;span class=

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. wink

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

QuestionForm edit

Subject Issue in browser
Status Answered
Related Topics
Topic revision: r5 - 28 Oct 2015, LynnwoodBrown - This page was cached on 25 May 2017 - 14:44.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License