We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40757
    • 11 Posts
    Hi,
    I want to have three boxes with text on my startpage, and I want the text in the boxes to easely be changed. Can I make a page for each box and then import the content from that page to the starpage and the specific box?

    Example:
    I create a page called "Textbox 1" and its content is imported into a div called "textbox1" on the startpage.

    Thank you!
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      That's what TV's are for. Create a rich text TV, associate it with the template for the home page. Then call the TV into the page like this:

      [[*TextBox1]]


      You can wrap the code above in a div to style it.
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 3749
        • 24,544 Posts
        You could also put the text in chunks and use a chunk tag where you want it to appear:

        [[$textBox1



        Actually, there are many different ways to do this in MODX. Which one is best depends on who will be setting the options, how often they will change, what's in the text boxes, and how convenient you want to make it to change the options.


        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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
          • 10208 ☆ A M B ☆
          • 1,780 Posts
          I often wish chunks were as available as TV's are when editing a resource (although quick edit works well enough). It'd be nice to have the chunks used on a page right there as TV's are, many are simply html (rich text editable) anyway. Associating chunks to resources would be ideal.

          For the OP, a TV would be the most editable way to do this, although a chunk would be more effective as you could call the chunk anywhere in the site and output the same content as needed. TV's are resource specific. Meaning if you edit a TV in one page, you will have to duplicate it on any other page (in the same TV) you wish to use the same content on. TV's follow the template, but only act on the resource (page) they are modified with.

          unless... you make the TV global with something like getResources and call up a hidden resource for output that uses your global TV's. In this case, a single TV would work on all pages.


            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 39932
            • 483 Posts
            You could do this easily with a custom Snippet. As BobRay said, there are lots of ways to do this sort of thing in MODX.

            Using Frogabog's example:

            Make a TV with the Chunk Name (we'll call it 'myspecialchunk')

            Make a Snippet with the following code:

              $name = $modx->resource->getTVValue('myspecialchunk');
              if (!empty($name))
                  return $modx->getChunk($name, array());
              return;
            


            Going further with Frogabog's example:
              $id = empty($id)
                  ? 1  //  <-- Some default resource
                  : $id;
              if ($id > 0)
              {   $resource = $modx->getObject('modResource', $id);
                  if (!empty($resource))
                  {   $name = $modx->resource->getTVValue('myspecialchunk');
                      if (!empty($name))
                          $output = $modx->getChunk($name, array());
                  }
              }
              return $output;
            



            Alternatively, you could also make a Snippet to just get the content of the Resource

              $id = empty($id) 
                  ? 1  //<--- set this to a default Resource ID
                  : $id;
            
              $output = 'Some default output';
              if ($id > 0)
              {   $resource = $modx->getObject('modResource', $id);
                  if (!empty($resource))
                      $output = $resource->get('content');
              }
              return $output;
            


            Lots'o'ways!! [ed. note: fuzzicallogic last edited this post 14 years, 2 months ago.]
              Website: Extended Dialog Development Blog: on Extended Dialog
              Add-ons: AJAX Revolution, RO.IDEs Editor & Framework (in works) Utilities: Plugin Compatibility List
              Tutorials: Create Cross-Context Resources, Cross-Context AJAX Login, Template-Based Actions, Remove Extensions from URLs

              Failure is just another word for saying you didn't want to try. "It can't be done" means "I don't know how".
              • 4172
              • 5,888 Posts
              Hi,
              I want to have three boxes with text on my startpage, and I want the text in the boxes to easely be changed. Can I make a page for each box and then import the content from that page to the starpage and the specific box?

              Example:
              I create a page called "Textbox 1" and its content is imported into a div called "textbox1" on the startpage.

              Todo it this way you could just use the getResources-snippet to get the boxes from other Resources content.

              You could also use a MIGX-TV where you can have a Textbox per Item and can add as many of them as you want.

              If its a fix count of 3 Textboxes you can also use three richtext or textarea-TVs

              The possibilities are endless in MODX
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 40757
                • 11 Posts
                Thank you so much for your replies, very helpful! smiley