We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22897 ☆ A M B ☆
    • 209 Posts
    I am setting up a business website using MODx. Rather than having the entire ’content area’ of the page editable, on certain pages I only want regions of it to be editable.

    I have read the documentation about TV’s but do not understand how to apply them in my cases. Here’s a couple of sample scenarios:

    Home page
    This has a fancy layout, and in order to stop the people editing the page from destroying the layout, I’d like to restrict the areas they can edit to the bits shown in green. Somehow they want the ability to add new boxes in the right column without destroying the page layout... so repeating regions?

    ’Our Staff’ page
    This is like a ’latest news’ page - it comprises of repeating regions all down the page. For each member of staff, the client needs to upload an image and enter the details shown in the image.

    I *could* have them edit the entire page here, but if they did the layout would become variable between each staff member’s biography (I might have to resort to tables!)



    There’s plenty of other pages like these on the site (job postings etc) but those seem to have a way to be done with existing MODx plugins.

    I can do (much) of this using TinyMCE’s noneditable plugin, but as a CMF I’d prefer to store the fields separately in the DB.

    So.. how should I tackle this? Does MODx do componentised data storage? I don’t want to have template variables flapping around on non-associated pages, so I think I have to create an entire copy of the main site template for each of the above pages?
      MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Yes, that’s what TVs are for. At the simplest level, just create TVs with rich text or textarea input. Now in your content or the template, call them : [*#upperLeft*], [*#upperRight*], etc. Notice the # added to make that section get its own Edit button.

      The repeated sections should be handled by each staff member getting his own page, and use Ditto on the main "staff" page to list them. That way members can be added or edited without bothering the rest of them. On one site, I have a snippet to determine if the viewer is logged in to edit or not; if he is, it displays a menu of the individual pages so he can go to them for editing. My Ditto template doesn’t provide any links, just the listings.
        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
        • 8960
        • 150 Posts
        Quote from: sottwell at Apr 12, 2007, 07:57 AM

        On one site, I have a snippet to determine if the viewer is logged in to edit or not; if he is, it displays a menu of the individual pages so he can go to them for editing. My Ditto template doesn’t provide any links, just the listings.

        Care to share that with us, Susan? Pretty please?
          • 22897 ☆ A M B ☆
          • 209 Posts
          Thanks Susan... do I have to replicate the entire template in order to bind different TV’s to different pages, or can I create sub-templates that inherit from the main page template, and allow me to only alter the section where the page content goes, binding in TVs?

          Sorry if that’s not clear smiley What I’m aiming for is not having irrelevant TV boxes showing on pages in the management area, which will confuse the people using the site ("I put content in this box but it didn’t show up")
            MAPLEDESIGN MODX development and MODX web design and custom development. Proud to serve UK and International clients!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            <?php
            $id = $modx->documentIdentifier;
            // make links to documents for QuickEdit editing if user is logged in to Manager
            if(isset($_SESSION['mgrInternalKey'])) {
                return $modx->runSnippet('Wayfinder', array('startId'=>$id,'level'=>'1','removeNewLines'=>'1','rowTpl'=>'PeopleLinks','textOfLinks'=>'pagetitle'));
            } else {
                return $modx->runSnippet('Wayfinder', array('startId'=>$id,'level'=>'1','removeNewLines'=>'1','rowTpl'=>'PeopleAnchors','textOfLinks'=>'pagetitle','titleOfLinks'=>'alias'));
            }
            ?>


            The PeopleLinks chunk and the PeopleAnchors chunk are almost the same; one makes the list ordinary links to the individual pages for editing, the other makes a list of anchors for internal page links. You could remove that else part if you don’t want the anchors.
            <li><a href="[+wf.link+]">[+wf.linktext+]</a></li>

            <li><a href="[~[*id*]~]#[+wf.title+]">[+wf.linktext+]</a></li>

            Make the anchor "name" tags in your Ditto template.
            <a name="[+alias+]" ></a>
            <h4>[+pagetitle+]</h4>
            [+tvPhoto+]
            <div class="info">
            <p>[+introtext+]</p>
            <p class="mail"><a href="mailto:[+longtitle+]">[+longtitle+]</a>  </p>
            <p class="phone">[+description+]</p>
            </div>
            <div class="bio">
            [+content+]
            </div>
            <div class="ruler"> </div>

            As you can see, I took the easy way and used the longtitle field for the person’s email address, and the description field for their phone number. You could also use TVs for those values, as I did for the photo.
              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
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Quote from: pbowyer at Apr 12, 2007, 08:36 AM

              do I have to replicate the entire template in order to bind different TV’s to different pages
              Yes, I’m afraid you do. TVs are template variables, after all, and are attached to templates. At this point in MODx development, anyway. I’m rooting for having categories for documents, and being able to assign TVs to categories.
                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