We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40088
    • 708 Posts
    I'm using some placeholders as part of member extended profile. They work ok but I need more flexibility over their output, like what's possible with a TV. So I'm wondering if it's possible to pass the value of a placeholder to a TV so I can tap into the flexibility/options a TV offers?

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

      Todd
      • 3749
      • 24,544 Posts
      I'm not clear on what you would gain from that over putting the HTML you want in the template, page content, or a chunk. Can you give an example of what you want to do?
        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
        • 40088
        • 708 Posts
        For example, using a placeholder as a link.
        <a href="[[+website]]" title="[[+website]]">My Website</a>

        This works perfectly because the 'website' placeholder is required thus it will always have a value. But other placeholders are optional so if they don't have a value then a hard-coded link will still show link text, except that it goes nowhere.

        Using a TV neatly skirts that problem since I can set the TV > Output Options > URL > Display Text field to whatever I want, and if there is no placeholder value to use then there won't be a dead link, it'll just be an empty field which is ideal.
          Todd
          • 3749
          • 24,544 Posts
          I don't use TVs for stuff like that (actually, I almost never use them at all), so I'm not sure how URL TVs work, but wouldn't you get this as a result of the TV if there's no URL?:

          <a href="" title="">My Website</a>


          You probably know this, but you can do the same thing with something like this:

          [[+website:isempty:then=``:else=`<a href="[[+website]]" title="[[+website]]">My Website</a>`]]
            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
            • 40088
            • 708 Posts
            Your example is very close, but even when there is no value the link text (e.g. My Website) is still being rendered. Shouldn't the "else" take care of that too?

            [ed. note: todd.b last edited this post 11 years, 6 months ago.]
              Todd
              • 3749
              • 24,544 Posts
              Can you paste your tag here? If the placeholder is empty, there should be no output at all.
                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
                • 40088
                • 708 Posts
                Here's an example:
                I have an optional (Profile) placeholder named [[+twitter]].
                [[+twitter:isempty:then=``:else=`<a href="[[+twitter]]" class="icon-twitter" title="[[+twitter]]">Twitter</a>`]]

                Even without a value the link text (Twitter) is still rendered.
                  Todd
                  • 3749
                  • 24,544 Posts
                  I probably have it wrong, I never use conditional output modifiers.


                  Try it this way:
                  [[!+twitter:isempty =``:else=`<a href="[[+twitter]]" class="icon-twitter" title="[[+twitter]]">Twitter</a>`]]


                  Actually, the If snippet may be a better choice here (though you have to install it). It would look something like this:

                  [[!If?
                     &subject=`[[+twitter]]`
                     &operator=`empty`
                     &then=``
                     &else=`<a href="[[+twitter]]" class="icon-twitter" title="[[+twitter]]">Twitter</a>``
                  ]]

                    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
                    • 40088
                    • 708 Posts
                    Neither one quite works.

                    Your alternate code still outputs link text for an empty placeholder.

                    And the If snippet output is always blank, even if a placeholder value does exist.

                    I must be missing something obvious and simple.
                      Todd
                    • discuss.answer
                      • 3749
                      • 24,544 Posts
                      Try it this way:

                      [[!If?
                         &subject=`[[!+twitter]]`
                         &operator=`empty`
                         &then=``
                         &else=`<a href="[[!+twitter]]" class="icon-twitter" title="[[!+twitter]]">Twitter</a>``
                      ]]
                        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