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

Answered TV with html tag

    • 24007
    • 38 Posts
    Hello,


    Scenario
    I've created a few TVs with the output type HTML Tag. The tag being used for each is blockquote and for continuity I've named the TVs 'blockquote1','blockquote2','blockquote3'
    In my CSS I've used the pseudo classes before and after to add right and left curly quotations respectively.

    On documents (resources) I may only require 1 or 2 blockquotes. Presently if I do not enter anything into the blockquote TVs I still end up with curly quotes.

    Question
    Is there a means of detecting if anything is added to the input of the TV and if the result is null, preventing the TV from being parsed client side on browser render.
    If this were not possible is there an approach to the user showing or hiding each TV throught the document editing section (temmplate variables tab)

    The convoluted method that first came to mind was to create 3 different templates and have each template assigned the requisite number of blockquote TVs; logic dictates that there has to be a more efficient and streamlined solution.

    Many thanks

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

      • 33379
      • 110 Posts
      You can add radio button tv's that toggle the blockquote's css visibility value from "visible" to "hidden" by swtching between two chunks with different css, or change position values to somewhere off the page. i.e. top:-500px (depending on the size of the object. I have done this on sites where the client wants to be able to show or hide certain objects for seasonal reasons etc.

      Let me know if you need more detail.

      Hope this helps - Mark
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        [[[[*blockquote1:notempty=`*blockquote1`]]]]

        You would need one of these for each of your blockquote TVs, which could get slow.
          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
          • 24007
          • 38 Posts
          Quote from: zaphodx at Aug 28, 2014, 12:56 PM
          You can add radio button tv's that toggle the blockquote's css visibility value from "visible" to "hidden" by swtching between two chunks with different css, or change position values to somewhere off the page. i.e. top:-500px (depending on the size of the object. I have done this on sites where the client wants to be able to show or hide certain objects for seasonal reasons etc.

          Let me know if you need more detail.

          Hope this helps - Mark

          Thanking you for the reply.

          Okay so I worked out a way based on your suggestion.

          Created 3 TVs with input as radio button options (show/hide)

          • toggleBlock1
          • toggleBlock2
          • toggleBlock3

          [[*toggleBlock1]] inserted into style attribute of [[*blockquote1]] (remembering that [[*blockquote1]] output is set to HTML Tag)

          2 chunks for each toggleBlock TV

          [[$showBlock1]]
          [[$hideBlock1]]

          [[$showBlock2]]
          [[$hideBlock2]]

          [[$showBlock3]]
          [[$hideBlock3]]

          [[$showBlock1]] chunk contained css style parameter:> display:block;
          [[$hideBlock1]] chunk contained css style parameter:> display:none;

          I used display rather than visibility to remove any empty space that may be hanging when visibility is set to hidden.


          Was this kind of what you had in mind?

          Many thanks
            • 24007
            • 38 Posts
            oops just noticed your reply on refresh Susan, not come across the syntax you posted, could you just expound on it a little?
            • discuss.answer
              • 4172
              • 5,888 Posts
              why not using a MIGX-TV, where you can add no or as many blockquotes as you like.
              This would just work, no conditionals needed.
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                That is the "tag as output" syntax for output modifiers. If the value is not empty, then it outputs the specified tag (that's what the outer set of brackets does).

                See Jason's blog post http://modx.com/blog/2012/09/14/tags-as-the-result-or-how-conditionals-are-like-mosquitoes/
                  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
                  • 33379
                  • 110 Posts
                  I think Bruno17's suggestion is a better solution if each blockquote will look the same. For my purposes the elements were all quite different and appeared on various pages throughout the sites using getResourceField, so being easier to create each as a separate tv with it's own formatting.
                    • 24007
                    • 38 Posts
                    I'm certainly going to investigate the MIGX-TV for another project I have lined up.