We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 48258
    • 3 Posts
    Hello guyes, I'm newcomer in modx, so I learn that CMS. I setup BootStrapTemplate and components which are needed to make it work. I expected everything should work fine from a box with basic components, but I got parser error here:
    <!DOCTYPE html>
    <html lang="[[++cultureKey]]">
        <head>
            [[$Head]]
        </head>
        <body>
            [[$Navbar]]
            <div class="container">
            [[!If?
                &subject=`[[RenderBreadcrumbs]]`
                &operator=`!empty`
                &then=`[[$Breadcrumb]]`
            ]]
            [[If?
                &subject=`[[*longtitle]]`
                &operator=`!empty`
                &then=`<div class="page-header">
                    <h1>[[*longtitle]]</h1>
                </div>`
            ]]
            [[!If?
                &subject=`[[RenderSidebar]]`
                &operator=`!empty`
                &then=`<div class="row">
                    <div class="col-md-2 sidebar-offcanvas" id="sidebar" role="navigation">
                        [[$Sidebar]]
                    </div>
                    <div class="col-md-10">
                        [[*content]]
                    </div>
                </div>`
                &else=`[[*content]]`
            ]]
            </div>
            [[$Footer]]
        </body>
    </html>
    

    It is completely basic. But in result, it does not work properly. In cases where there is [[RenderSideBar]] is not passed it does not show [[*content]] in any way, but I also do not see ` missed by parser. In cases when it is passed, I see ` before <div class="row">, and &else=`Conte , that means parser does not parse [[!if? correctly. I can't understand what may cause such problem and where I should look for a way to fix it.

    Any suggestions are appreciated...
    Thanks.

    This question has been answered by cleric. See the first response.

    [ed. note: smashingred last edited this post 12 years, 3 months ago.]
      • 27708 MODX Staff
      • 2,502 Posts
      I'd be curious to know what the RenderSidebar snippet is returning and if it's ever empty.
        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
        • 3749
        • 24,544 Posts
        Jay, this sounds just like several other issues I've seen with the parser lately. If you read the last paragraph carefully, you can see that the back-ticks are showing up in the output.

        The only way that could happen, imo, is that the back-ticks in the snippet tag are being passed to the snippet in the $scriptProperties array. That should never, ever happen.

        I've seen this reported with NewsPublisher:

        In the tag:
            &show=`tv1,pagetitle,tv2,tv3`


        Error output:
            TV not found: `Tv1
            TV not found: Tv3`


        I've also seen it reported for the another snippet, and now the If snippet. It's starting to look like a critical bug in the parser. I haven't been able to replicate it, but if there have been any changes to the parser code lately, they deserve another look.

        I reported this issue at GitHub, but don't see my report in the issues there.



          Did I help you? Buy me a beer
          Get my Book: MODX:The Official Guide
          MODX info for everyone: http://bobsguides.com/modx.html
          My MODX Extras
          Bob's Guides is now hosted at A2 MODX Hosting
        • discuss.answer
          • 48258
          • 3 Posts
          Yes problem in parser, perhaps in back-ticks

          Code:
          [[!If?
          			&subject=`[[RenderSidebar]]`
          			&operator=`!empty`
          			&then=`<div class="row">
          				<div class="col-md-2 sidebar-offcanvas" id="sidebar" role="navigation">
          					[[$Sidebar]]
          				</div>
          				<div class="col-md-10">
          					[[*content]]
          				</div>
          			</div>`
          			&else=`[[*content]]`
          		]]

          Output:

          <div class="container">
          		
          		<div class="page-header">
          				<h1>Level 2 long title</h1>
          			</div>
          		`<div class="row">
          				<div class="col-md-2 sidebar-offcanvas" id="sidebar" role="navigation">
          					<div class="well sidebar-nav">
          	  <ul><li class="first"><a href="level2/level3.html" title="Level 3 Dco" >Level 3 Dco</a></li>
          </ul>
          </div><!--/.well -->
          				</div>
          				<div class="col-md-10">
          					<p>Content Rjklfjglkf арплвапрлвор</p>
          				</div>
          			</div>`
          			&else=`<p>Co
          		</div>