We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 29059
    • 88 Posts
    been trying to figure this out all day. have poured over these forums, the documentation, & the wiki.
    i feel i’ve gotten very close, but am still missing a few key things. so any help would be much appreciated.
    please note also that i’m new to ModX - using it on my first client site now, but i LOVE it!

    so, i want to be able to allow the client to create content for the sidebar of the site i did, but want that single content to appear in the sidebar of most of the other pages without the client having to copy/paste from one "template variable" on one page to another.

    pretty much a "php include" would rock - ’tis what i’ve done previously and given the client the ability to edit a simple txt doc. but i think i can do much better with modx.

    so here’s where i’ve gotten...

    1) i created a new document called "sidebar" and gave it NO template assignment

    2) i created a new template variable with these specs...
    - variable name: sidebardocument
    - caption: Include SideBar doc
    - Description: Auto SideBar Inclusion
    - Input Type: huh (i don’t know what to choose here. i chose checkbox for now. will explain why below)
    - Input Option Values: huh (i don’t know what to do here)
    - Default Value: @DOCUMENT 218 (#218 is the number of the above created "sidebar" document)
    - Template Access: i checked the templates i want this in

    okay, so this works - sorta.
    the content created in the sidebar document ’does’ show up on all the pages that the sidebardocument template variable is linked to.
    so that’s successful.

    but what about the "input type" and the "input option values" for this template variable?

    the checkbox is useless. when you go in to edit one of the pages that this TV is linked to, it does show the checkbox and any text i put into the "input option values" field, but it doesn’t do anything to it - no affect.

    i thought it would be really cool to have this as an "option" for the client. so they could choose whether or not to have the content they create in the sidebar doc show up in the doc they’re editing. so i though the checkbox here would turn the feature on or off. but it doesn’t. so then i read somewhere that radio buttons work better - tried that, but still, no affect.

    do i need to put some sort of "show/hide" code in there?
    i read that the @EVAL command might be the route to go, but i’m not sure. and i don’t know the php code i would need to know for this.

    so please help here.
    THANKS,
    -jason.
      • 25663 MODX Staff
      • 12,272 Posts
      How frequently is the sidebar content going to change, or is it more likely to be one of a few options per section throughout your site?
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 29059
        • 88 Posts
        it could change quite frequently. i think my client wants to use it as a "special deals" and "announcements" or "news" type area.
          • 25663 MODX Staff
          • 12,272 Posts
          If it’s going to change on pretty much every page, just create a textarea type and let them have full reign over every page. That way they get a RTE instance and total control.

          If you want to be able to offer them an "almost used every time" TV option, then just give the TV a default value. There’s lots of ways to make this more complex, but consider weighing complexity with the value of what the clients can understand.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 34017
            • 898 Posts
            Ryan,

            How could he create a checkbox that would:

            - if checked, show contents of an article
            - if not checked nothing.
              Chuck the Trukk
              ProWebscape.com :: Nashville-WebDesign.com
              - - - - - - - -
              What are TV's? Here's some info below.
              http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
              http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008
              • 22303 MODX Staff
              • 10,725 Posts
              Place a wrapper snippet in the template to include the content of the article based on the status of a checkbox TV?
                • 29059
                • 88 Posts
                hi guys,
                thanks for the help thus far, but i guess i’m still not understanding (please be patient with me)...

                TO: "rthrash" - what does "RTE" stand for? also, if i’m understanding you correctly (probably not), i already have created a TV for the client to optionally enter content into the sidebar for each individual page. but in addition to that, i want them to be able to enter content into "one" area and have it show up on multiple pages if they so choose by simply saying "yes" or "no" (show/hide) in the TV area of an editable doc.

                TO: "opengeek" - what do you mean? can you go into "much" greater detail on how to do that please?

                TO: "prowebscape" - thanks for "getting it" ;-)


                  • 7231
                  • 4,205 Posts
                  You can do this with the TVConditional snippet.

                  1) setup a checkbox TV with a value for example ’yes’
                  2) create a chunk to be displayed if the checkbox is selected
                  3) add to your template the TVConditional call:
                  [!tvcnd? &tv=`tvName` &cnd=`yes, 2` &rtn=`chunkName`!] Which in this case will show the chunk if the TV value is equal to ’yes’.

                  TVConditional: http://www.modxcms.com/TV-Conditional-607.html

                  Then to get the content of the other page add the getField snippet (or a custom wrapper) in the chunk to be displayed.

                  This is the low tech way to get this done. You could also create a snippet that did all this in one step.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don't know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 29059
                    • 88 Posts
                    okay guys.
                    first, thanks for the quick responses. much appreciated!
                    second, please be more patient with me as i’m more of a designer than a programmer.
                    can you give me a 1,2,3 step process with precise language please?

                    here’s what i’ve done based off your instructions - but it’s not working...

                    1) created the "TVcnd" snippet as downloaded from http://www.modxcms.com/TV-Conditional-607.html
                    2) created the "GetField" snippet as downloaded from http://modxcms.com/getField-667.html
                    3) uploaded the "getfield.inc.php" file as instructed to from http://modxcms.com/getField-667.html
                    4) changed my "sidebardocument" TV to...
                    4a) Input Type: Check Box
                    4b) Input Option Value: Yes
                    4c) Default Value: (empty)
                    5) added this code to my document templates...
                    [!tvcnd? &tv=`sidebardocument` &cnd=`yes, 2` &rtn=`sidebarchunk`!]
                    6) created the "sidebarchunk" chunk but couldn’t figure out what to put in it, so i put this...
                    [[getField? &docid=`218`]]
                    ...because #218 is the template-less document i created for sidebar content
                    7) i went to edit a page and checked the check box
                    8) when i view the page, i actually see the word "yes" and then the code from step 5 above instead of the content of the referenced doc.

                    again, thanks for your patience and help!!!
                    -jason.
                      • 34017
                      • 898 Posts
                      It looks like you left off which db field to show. Change your code to:
                      [[getField? &docid=`218` &field=`content`]]
                      


                      If that doesn’t work, you may be able to do this. Put the following code wherever you want the document to show. (So many different ways to do things....)

                      [+phx:if=`[*sidebardocument*]`:is=`yes`:then=`[[getField? &docid=`218` &field=`content`]]`+]
                      


                      PS - make sure PHx is installed if you try the second option.
                        Chuck the Trukk
                        ProWebscape.com :: Nashville-WebDesign.com
                        - - - - - - - -
                        What are TV's? Here's some info below.
                        http://modxcms.com/forums/index.php/topic,21081.msg159009.html#msg1590091
                        http://modxcms.com/forums/index.php/topic,14957.msg97008.html#msg97008