We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42465
    • 33 Posts
    I hope the title explains the issue. I'm looking to output the TVs associated with the home page on all internal pages.

    Right now the chunk containing the TVs looks like this:

    <ul>	
        <li><a href="[*footerImageOneLink*]" target="_blank"><img src="[*footerImageOne*]" /></a></li>
        <li class="last"><a href="[*footerImageTwoLink*]" target="_blank"><img src="[*footerImageTwo*]" /></a></li>
    </ul>
    


    The idea is that the images and their associated links can be set in on place and applied globally. I don't think I can use getField as there are 4 TVs in total.

    Suggestions welcome.

    This question has been answered by multiple community members. See the first response.

      • 13428 ☆ A M B ☆
      • 1,031 Posts
      I would use multiTV for that. You could generate the list elements with only one multiTV template variable.

      You could use @INHERIT in the template variable or call the multiTV snippet with &docid parameter to have a global resource, containing the footer links.
        • 42465
        • 33 Posts
        I'm not overly familiar with @ Bindings so I'll have to do a bit of research. Unfortunately the official docs I've found so far are quite poor, e.g. http://rtfm.modx.com/evolution/1.0/developers-guide/template-variables/%28at%29-binding/%28at%29inherit (examples are always good). I'm checking out the link you gave and it seems pretty cool. Will have to investigate further.

        Thanks

        p.s. the excuse the state of the above url.
          • 13428 ☆ A M B ☆
          • 1,031 Posts
          @INHERIT means that the content of the template variable is inherited from the parent resource.
            • 42465
            • 33 Posts
            OK, Thanks. My understanding is that @inherit will only cascade down a particular resource and if so I don't think that it will work in this case as the resource that has the TVs enabled is at root level along with a bunch of others. If this is the case then multiTV might be my best option.
            • discuss.answer
              • 4310
              • 2,310 Posts
              Below is a very quick & dirty snippet to achieve your goal :
              <?php
              $home_id = isset($home_id)?$home_id: 1;
              $myArray = $modx->getTemplateVarOutput(array('footerImageOneLink','footerImageOne','footerImageTwoLink','footerImageTwo'), $home_id);
              $output = '<ul>  
                  <li><a href="'.$myArray['footerImageOneLink'].'" target="_blank"><img src="'.$myArray['footerImageOne'].'" /></a></li>
                  <li class="last"><a href="'.$myArray['footerImageTwoLink'].'" target="_blank"><img src="'.$myArray['footerImageTwo'].'" /></a></li>
              </ul>';
               return $output;
              ?>
                • 25803 ☆ A M B ☆
                • 721 Posts
                I use fastField for exactly this purpose.

                So you would make a chunk like this (we'll say your document ID is 7:

                <ul> 
                    <li><a href="[[#7.tv.footerImageOneLink]]" target="_blank"><img src="[[#7.tv.footerImageOne]*]" /></a></li>
                    <li class="last"><a href="[[#7.tv.footerImageTwoLink]]" target="_blank"><img src="[[#7.tv.footerImageTwo]]" /></a></li>
                </ul>
                


                I tend to make a context setting for an admin document (i.e. a document that the client edits for global content) such as admin_doc_id so the call becomes:

                <ul> 
                    <li><a href="[[#[[++admin_doc_id]].tv.footerImageOneLink]]" target="_blank"><img src="[[#[[++admin_doc_id]].tv.footerImageOne]*]" /></a></li>
                    <li class="last"><a href="[[#[[++admin_doc_id]].tv.footerImageTwoLink]]" target="_blank"><img src="[[#[[++admin_doc_id]].tv.footerImageTwo]]" /></a></li>
                </ul>
                


                This way, if you create multiple contexts, you can have different admin docs per context, if necessary.

                There is also the ClientConfig extension as an alternate way to manage global variables but be warned it isn't context sensitive.
                • discuss.answer
                  • 13428 ☆ A M B ☆
                  • 1,031 Posts
                  @bunk58: Should be the fastest solution. But if he wants to manage multiple footer images/links with the possibility to add new images/links without adding new template variables multiTV is more flexible.

                  @rx2: Its the Evo section here.
                    • 25803 ☆ A M B ☆
                    • 721 Posts
                    Sorry. Didn't notice that.
                      • 42465
                      • 33 Posts
                      Thanks guys!

                      I'll experiment with both.