We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25803 ☆ A M B ☆
    • 721 Posts
    I'm attempting to build a one-page site with a Bootstrap 3 based template. As background, one of things we often do is develop a Global Content page for some items that the client may want to display here and there throughout the site or may not.

    Have switched to pdoTools (pdoResources and pdoMenu) as it has been reported that it performs better than getResources and Wayfinder.

    On the Global Content page, we have a MIGX TV called assocations. Within that it uses 2 TVs, image (type:image) and url (type:url).

    We created a chunk called showAssociations with following code:

    <div class="row">
        <h3 class="text-center">[[#[[++global_id]].tv.assocationsTitle]]</h3>
        [[!getImageList? 
        &tvname=`associations`
        &tpl=`assocationsTPL`
        &docid=`[[++global_id]]`
        &placeholdersKeyField=`idx`
        ]]
    </div>
    


    [[++global_id]] is a context setting which identifies the ID of the Global Content resource.

    The template, associationsTPL is:

    <div class="col-lg-6 col-md-6 col-sm-12 col-xs-12">
        <a href="[[+url]]" target="_blank"><img src="[[+image:phpthumbof=`w=300&h=250&zc=1`]]" class="img-responsive center-block" /></a>
    </div>
    


    This works perfectly fine when rendering just that single resource (outside of the one page as it were).

    We've also created a TV called: showAssociations (same name as the chunk but since it's a TV that shouldn't be a factor I gather.
    This has been either a Single Select Drop Down or a Radio type of TV with values of Yes==1||No==no and default value of 0. The intention is that when a user is editing a page, they can choose whether or not to show the associations on that page (which is used to create a section in the one page site). But we'll dismiss that for now and look at how the resource is integrated into the one page site, using pdoTools.

    We've created a home page has a template which assembles each section of the one page by gathering information from resources under a Sections blank container document. We have a chunk called getContent with the following code:

    [[pdoResources?
        &parents=`[[+section_id]]`
        &depth=`0`
        &includeContent=`1`
        &showHidden=`0`
        &resources=`-12`
        &includeTVs=`showAssociations`
        &showLog=`1`
        &tpl=`sectionTPL`
    ]]
    


    For the sectionTPL we have this:

    <div id="[[+alias]]" class="section anchor">
        <div class="light-wrapper">
          <div class="container inner">
            <h2 class="section-title text-center">[[+pagetitle]]</h2>
            <p class="lead main text-center">[[+introtext]]</p>
            [[+content]]
            [[$showAssociations]]
            [[+tv.showAssociations]]
          </div>
          <!-- /.container --> 
        </div>
    </div>
    


    We've thrown in [[+tv.showAssociations]] to see that we get a return value for when we attempt to make it conditional. But before that, we need the chunk [[$showAssocations]] to render. It doesn't.

    However, if we get rid of the chunk entirely and replace it with the content within the chunk like so:

    <div id="[[+alias]]" class="section anchor">
        <div class="light-wrapper">
          <div class="container inner">
            <h2 class="section-title text-center">[[+pagetitle]]</h2>
            <p class="lead main text-center">[[+introtext]]</p>
            [[+content]]
            <div class="row">
            <h3 class="text-center">[[#[[++global_id]].tv.assocationsTitle]]</h3>
            [[!getImageList? 
            &tvname=`associations`
            &tpl=`assocationsTPL`
            &docid=`[[++global_id]]`
            &placeholdersKeyField=`idx`
            ]]
            </div>
            [[+tv.showAssociations]]
          </div>
          <!-- /.container --> 
        </div>
    </div>
    


    It renders.

    I'm obviously not familiar with what's going on for parsing. How do we get the chunk to parse? Is there some sort of setting in pdoResources or this is simply not possible?