We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21417
    • 486 Posts
    Hello,

    I am using EVO 1.0.4 with Wayfinder 2.0

    I am using Wayfinder to display tabular product data comprising of: part number, description, image and file downloads

    The image and file downloads are included as template variables.

    It is working really well for me except with the file downloads where I am a little stuck and need the help of a coding guru.

    Not all products have file downloads - these as optional where none or any one, two or three can be selected - some have up to 3 different different file downloads:
    [+product-download-catalogue+]
    [+product-download-install-manual+]
    [+product-download-technical+]



    This is what I would like to happen:

    1. If a catalogue pdf is selected, include:
    <a href="[+product-download-catalogue+]" title="Catalogue for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>
    Otherwise, include nothing for this tv.


    2. If an installation pdf is selected, include:
    <a href="[+product-download-install-manual+]" title="Installation Manual for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>
    Otherwise, include nothing for this tv


    3. If a technical pdf is selected, include:
    <a href="[+product-download-technical+]" title="Technical Data for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>
    Otherwise, include nothing for this tv


    4. If no pdf is selected, nothing should be included in the output.


    My wayfinder row template looks like this - but the 3 links / pdf icons are also included for products that do not have pdf files:

      <tr>
       <td class="col1-4">[+wf.title+]</td>
       <td class="col2-4">[+wf.description+]</td>
       <td class="col3-4"><a href="[+product-image+]" rel="lightbox" class="th2" title="[+wf.title+] : [+wf.description+]"><img src="[+product-image+]" /></a></td>
       <td class="col4-4">
        <a href="[+product-download-catalogue+]" title="Catalogue for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>
        <a href="[+product-download-install-manual+]" title="Installation Manual for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>
        <a href="[+product-download-technical+]" title="Technical Data for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>
       </td>
      </tr>
      </tr>


    If I change it to the following, the tv values are inserted / ignored as relevant, but the formatting is not output and the link is not clickable.

      <tr>
       <td class="col1-4">[+wf.title+]</td>
       <td class="col2-4">[+wf.description+]</td>
       <td class="col3-4"><a href="[+product-image+]" rel="lightbox" class="th2" title="[+wf.title+] : [+wf.description+]"><img src="[+product-image+]" /></a></td>
       <td class="col4-4">[+product-download-catalogue+] [+product-download-install-manual+] [+product-download-technical+]</td>
      </tr>
      </tr>


    Eg: Instead of 3 x:
    <a href="[+product-download-technical+]" title="[+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>

    It returns 3 x:
    [+product-download-technical+]
    (eg assets/files/product1/product_Catalogue.pdf assets/files/product2/product2_Catalogue.pdf assets/files/product3/product33_Catalogue.pdf

    Can anyone think of a solution to make it work?

    Thanks in advance.
      Web design Adelaide
      http://gocreate.com.au
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You really shouldn’t use Wayfinder for this; Ditto would be a much better choice. Ditto uses TVs, and also has PHx embedded so you can use PHx conditionals in your Ditto tpl.

      The three main differences between Ditto and Wayfinder are

      1. Wayfinder generates nested structures to allow multiple level menus, Ditto generates a flat structure.
      2. Ditto allows many more variables, including TVs.
      3. Ditto has PHx embedded, to allow more flexibility in conditional templating.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 21417
        • 486 Posts
        This is a nested structure that’s why I am using wayfinder - its pulling info from the product brand, the product group and the product items and including the start item.

        eg
        + product brand
        - product group
        * product item
        * product item
        - product group
        * product item
        * product item

        Regardless how could I achieve this with Ditto? I am not a coder and this was the reason I asked the question.

        Anyone else?
          Web design Adelaide
          http://gocreate.com.au
          • 10449
          • 956 Posts
          Perhaps this might work: Create a little snippet that checks all three TVs. Create an output that will only show download-links when the TV has an actual value. At the end, create a placeholder.

          Include this placeholder somewhere in the Wayfinder tpl chunk. I have never tried the same thing, so I can’t guarantee this would work, but it’s worth a try.
            • 22427
            • 793 Posts
            You may use [tt]PHx[/tt] to prevent the output of an empty TV - perhaps like that:
            [+phx:if=`[+product-download-catalogue+]`:isnot=``:then=`<a href="[+product-download-catalogue+]" title="Catalogue for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>`+]

              • 10449
              • 956 Posts
              OK, I tried the hack I described above: It does not work.

              I was under the (false) impression that Wayfinder would automagically store any document variables inside the wf.foo scope, e.g.
              wf.introtext = doc summary/introtext, wf.tvName = tvName
              Alas, that ain’t so.

              I even tried a detour via the getField snippet placed inside the Wayfinder rowTpl... no dice either.

              Seems like WF is really very limited when it comes to such stuff... Hence, try PHx smiley
                • 21417
                • 486 Posts
                Thank you so much for your help Ottogal and ganeshXL.

                Thank you for confirming the snippet idea ganeshXL - that was a little above my head as I don’t know php so I went down the phx path.

                Ottogal, you are an absolute gem! That works perfectly - its exactly the solution I was looking for.

                To confirm for anyone interested:

                a. I downloaded and installed PHx from the MODx add ons

                b. I changed my wayfinder row template to include the phx calls for the 3 product download template variables

                  <tr>
                   <td class="col1-4">[+wf.title+]</td>
                   <td class="col2-4">[+wf.description+]</td>
                   <td class="col3-4"><a href="[+product-image+]" rel="lightbox" class="th2" title="[+wf.title+] : [+wf.description+]"><img src="[+product-image+]" /></a></td>
                   <td class="col4-4">
                [+phx:if=`[+product-download-catalogue+]`:isnot=``:then=`<a href="[+product-download-catalogue+]" title="Catalogue for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>`+]
                [+phx:if=`[+product-download-install-manual+]`:isnot=``:then=`<a href="[+product-download-install-manual+]" title="Installation Manual for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>`+]
                [+phx:if=`[+product-download-technical+]`:isnot=``:then=`<a href="[+product-download-technical+]" title="Technical Data for [+wf.title+]" target="blank"><img src="/assets/images/mix/pdf-icon.png" /></a>`+]
                   </td>
                  </tr>


                And whalah! it works a treat.

                  Web design Adelaide
                  http://gocreate.com.au