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

    I want to display a custom notice in my template if a user has set one.
    I already have done something similar for maintenance of a page with a TV. But this one should be a site-wide message anchored in template with a :notempty-output filter. How can I do this best? Could be done with a resource and getResources but getResources and a extra resource is very suboptimal for that purpose I think.

    So for me it would be the perfect solution to create a TV which can be attached to all documents not just to one. wink

    Any thoughts?
      MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)
      • 33968
      • 863 Posts
      Hi, I may have misunderstood smiley

      You want to display the same message anywhere on the site, but have it show or hide for each page depending on a TV?
      I guess you could do something like this:

      Input Type: Check Box
      Input Option Values: Show==[[$siteWideChunk]]
      Default Value:
      Output Type: Default

      Then create the [[$siteWideChunk]] or whatever you want to call it and put your notice in there.

      Remember to set access to all templates for that TV.

      Is that what you intended?
        • 21838
        • 284 Posts
        Quote from: lucas at Apr 11, 2011, 03:56 AM

        Hi, I may have misunderstood smiley
        You want to display the same message anywhere on the site, but have it show or hide for each page depending on a TV?
        I guess you could do something like this:

        Input Type: Check Box
        Input Option Values: Show==[[$siteWideChunk]]
        Default Value:
        Output Type: Default

        Then create the [[$siteWideChunk]] or whatever you want to call it and put your notice in there.
        Is that what you intended?
        Sorry, that’s the thing I actually have. But I wanted to have a solution where I don’t have to set on each page. I want to show or not show a TV content on the whole website with one click. Do you understand?
          MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)
          • 33968
          • 863 Posts
          Hmm I see what you mean. Don’t know how you could do that with a TV, unless you used @select to grab the content of your message TV from the database.

          I’d be thinking something like getResourceField

          [[getResourceField? &id=`XX` &field=`siteWideTV` &processTV=`1` &default=``]]

          Replace XX with the resource that holds your message TV.
          &default=`` means nothing will be output unless the TV has content.

          Would that work for you?
            • 36442
            • 97 Posts
            Another possible solution is to create your own System setting (go to System -> System Settings). You can get it then by [[++your_setting_key]], like any other template tag (pagetitle, alias, etc.).

            UPD. Actually, I think this is the best way, and this is for what System settings can be created. Whatch video here http://rtfm.modx.com/display/revolution20/System+Settings for more info.
              • 21838
              • 284 Posts
              Quote from: Warsteiner at Apr 11, 2011, 06:55 AM

              Another possible solution is to create your own System setting (go to System -> System Settings). You can get it then by [[++your_setting_key]], like any other template tag (pagetitle, alias, etc.).
              UPD. Actually, I think this is the best way, and this is for what System settings can be created. Whatch video here http://rtfm.modx.com/display/revolution20/System+Settings for more info.
              Think actually this is the best option for me now.
              @lucas: This is another option but isn’t that smooth in handling. I think the intended way to solve sth. like that is a system setting.
              Thank you all!
                MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)
                • 33968
                • 863 Posts
                @Warsteiner - that is brilliant smiley

                Sometimes I feel I’m only scratching the surface of what MODx is capable of...
                  • 36442
                  • 97 Posts
                  Yet another way is to use a chunk, which can be more user-friendly and flexible.
                    • 17016
                    • 138 Posts
                    What about adding this to your template:

                    [[!If? &subject=`[[$your_individual_junkname]]` &operator=`!=` &operand=`` &then=`[[$your_individual_junkname]]`]]

                    Letti
                      • 21838
                      • 284 Posts
                      Quote from: Letti at Apr 11, 2011, 07:20 AM

                      What about adding this to your template:
                      [[!If? &subject=`[[$your_individual_junkname]]` &operator=`!=` &operand=`` &then=`[[$your_individual_junkname]]`]]
                      Actually this would work, too. For users, both solutions aren’t optimal as i can’t provide a RTE in chunks.
                      To summarize: If it’s about variable/editable content, chunk-solution is better (with If-snippet), if it’s about static content I’d prefer system-settings.
                        MODX Free Template Base: MODX-Boilerplate | my blog (lots of MODX stuff) | my gitHub (translations) | MODX User Groups Germany (Facebook)