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

    Although you can automatically pull content from pages or containers using Ditto, entering a Ditto call is not all that user-friendly from a client’s point of view (for our clients anyway). To give this kind of power to clients, is it possible to use checkboxes/drop-down lists to pull content from containers or pages or even create new TVs in the manager so the client could enter a document ID to pull content from?

    e.g. Say we have a sidebar with four content slots in it. Could the client use a drop-down list to decide what goes in each box, and could the types of content in the list be as varied as:
    - A wayfinder subnavigation call with a new TV so the client could enter a particular document or container ID from which to start the navigation
    - A Ditto call that pulls news headlines in
    - A list of tags from a particular container or document
    - Latest comments from a particular container or document
    - A search box
    - A TV from another document
    - A rich Text block for the client to enter custom text for that particular page

    Obviously certain inputs would be required from the client (like document IDs so Modx knew where to get content from) but can new TVs be loaded into manager based on a user’s selection so that info could be collected?

    Not sure if this is all pie in the sky stuff but any pointers in the right direction would be appreciated.

    Cheers

    Ben
      • 5532
      • 251 Posts
      I guess chunks could be set up to hold Ditto/Wayfinder calls and html formatting with the drop-down list or check boxes linking to these and somehow generating new TVs in manager for the client to provide doc IDs - maybe?
        • 5532
        • 251 Posts
        OK, have done a bit of experimenting and come up with the following which is a slightly different take on Sue’s excellent example here: http://www.sottwell.com/tv-input-types.html. The main difference being that the client can put any of the items in the dropdown list into any order in the sidebar.


        Here’s how the finished "Edit Sidebar" tab looks in the manager:



        For my own reference, here are the instructions - please feel free to offer suggestions or simplify the process as I’ve only been working in Modx for a year (I’m also a designer with no PHP experience - which is the beauty of Modx IMHO).

        Firstly, I created 5 template variables which will hold 5 different sidebar content blocks, and inserted them into a sidebar chunk like this:
        <!-- START SIDEBAR -->
        <div class="sidebar">
        <div class="fade">
        [*sidebarBlock1*]
        [*sidebarBlock2*]
        [*sidebarBlock3*]
        [*sidebarBlock4*]
        [*sidebarBlock5*]
        </div>
        <!-- END SIDEBAR -->
        </div>



        Sub Navigation option
        So the client can put subnavigation into the sidebar when they want, I created a chunk with the following wayfinder call which starts the navigation from the containing folder using UltimateParent:
        [!Wayfinder? &startId=`[[UltimateParent]]` &outerClass=`subNavigation` &level=`1` &displayStart=`1` &startItemTpl=`subNavigationTitle`!]

        The call references the following template which makes a title that is also a link back to the section home page (or container) - again using UltimateParent:
        <a href="[~[[UltimateParent]]~]"><h3>[+wf.linktext+]</h3></a>
        [+wf.wrapper+]



        "News Headlines" option
        To insert the top 5 headlines onto any page, I created a chunk with the following Wayfinder call - which goes to the news container, grabs the child pages, sorts them by creation date and limits the output to 5 (&limit=`6` means 5 for some reason):
        [!Wayfinder? &startId=`58` &outerClass=`subNavigation` &level=`1` &displayStart=`1` &limit=`6` &startItemTpl=`newsHeadlinesTitle` &sortBy=`createdon` &sortOrder=`DESC`!]

        The Wayfinder call references the following template which also creates a title that links back to the news home page:
        <a href="/2010-news"><h3>News Headlines</h3></a>
        [+wf.wrapper+]



        Page Specific sidebar content
        I created a couple of TVs called "sidebarPageSpecific1" and "sidebarPageSpecific2" which will allow the client to insert sidebar content specific to that page.


        Site-wide sidebar content
        So the client can choose to have sidebar content common across the site, I created a page that isn’t searchable (or in the menu) called "Site-wide sidebar". This page has 4 Rich Text TVs on it. To grab the TVs and insert them into the sidebar, I setup a chunks for each named "dittoSiteWideSidebar1", "dittoSiteWideSidebar2" etc, and each one contains a Ditto call of:
        [!Ditto? &documents=`26` &tpl=`siteWideSidebar1`!]

        Each Ditto call references a unique template which grabs the required Rich Text TV: 1, 2, 3, 4 - actually, can you put a TV directly into a Ditto call? Wouldn’t need a template then:
        [+textBlock1+]

        This means that if one of the site-wide options is selected, Ditto will pull the content from that particular TV on the "Site-wide Sidebar" page and place it into the sidebar block.


        Putting the options into dropdown lists
        Going back to the original 5 sidebar TVs ([*sidebarBlock1*] etc) I made the following modifications to each one: Made them all dropdown lists by changing the input types to "Dropdown List" and inserted the following code into the "Input Option Values"...
        ||Sub Navigation=={{wayfinderSubNavigation}}||Top News Headlines=={{wayfinderNewsHeadlines}}||Page Specific Sidebar 1 (below)==[*sidebarPageSpecific1*]||Page Specific Sidebar 2 (below)==[*sidebarPageSpecific2*]||Site-wide Sidebar 1=={{dittoSiteWideSidebar1}}||Site-wide Sidebar 2=={{dittoSiteWideSidebar2}}||Site-wide Sidebar 3=={{dittoSiteWideSidebar3}}||Site-wide Sidebar 4=={{dittoSiteWideSidebar4}}

        This creates the menu items and references the various chunks and TVs.

        I then used ManagerManager: http://evolution.webprogramming.ca/assets/plugins/managermanager/docs/ to create a new tab in the Modx Manager interface called "Edit Sidebar" and moved all the sidebar related TVs (the 5 dropdown list TVs and the 2 page specific sidebar Rich Text TVs) into that tab.

        Now the client has a specific "Edit Sidebar" tab that contains the 5 drop down lists and the page specific Rich Text TVs like this:
        If the client chooses a Page Specific Sidebar from one of the lists, any text entered into the Page Specific Sidebar TVs below will appear in the sidebar for only that page.



        Issues/questions
        In addition to the above menu options, I’ve also created a Section Search option that if selected, will place a search box into the sidebar that will only search within that page’s container - that’s the theory anyway. I set up a chunk with the following AjaxSearch call (and a headline) which should travel up the document tree to the parent container and limit the search to pages within that container - again using Ultimate Parent:
         <div class="sidebarSearch">
        <h3>Search [~[[UltimateParent]]~]</h3>
        [!AjaxSearch? &ajaxSearch=`0` &AS_landing=`57` &AS_showResults=`0`!]
        </div>


        However, although selecting it in the menu makes the search box appear in the sidebar, any search query you type appears in the search box in the header. Does anyone know if it’s possible to have more than one search box on the same page?

        Also, I read about the @INHERIT binding on Sue’s site: http://www.sottwell.com/tv-bindings.html (Thanks Sue!) and was wondering if you can specify a document ID so that you could just grab content from TVs on specified documents without all those Ditto calls which bring in the site-wide sidebar items.

        Any help or improvement suggestions would be welcome.


        Cheers

        Ben
          • 5532
          • 251 Posts
          And while we’re on the subject of AjaxSearch, any suggestion on how to fix this "Remove Highlight" issue would be awesome!
          http://modxcms.com/forums/index.php/topic,44400.0.html

          Cheers

          Ben
            • 5532
            • 251 Posts
            I guess I could install parallel installations of AajxSearch using a name like ajaxSearchSection?
            Setup parallel installations

            If you want to install new version, but want to try it first and don’t want to replace your current AjaxSearch installation, you can do parallel setup.

            Extract the contents of the zip file to your computer
            Rename ajaxSearch folder in the extracted files to something else, for example ajaxSearch-new

            Open the extracted snippet.ajaxSearch.php and change define(’AS_SPATH’, ’assets/snippets/ajaxSearch/’); to
            define(’AS_SPATH’, ’assets/snippets/ajaxSearch-new/’);

            Open the extracted ajaxSearchPopup.php and change define(’AS_SPATH’, ’assets/snippets/ajaxSearch/’); to
            define(’AS_SPATH’, ’assets/snippets/ajaxSearch-new/’);

            Open the extracted js/ajaxSearch.js and change var _base = ’assets/snippets/ajaxSearch/’; to
            var _base = ’assets/snippets/ajaxSearch-new/’;

            FTP the ajaxSearch-new folder to your server under assets/snippets and the files and sub-folders will go to correct place. Go to MODx manager and create a new snippet called AjaxSearchNew and paste the contents of snippet.ajaxSearch.php to it

            Use AjaxSearchNew snippet call in some document and view results
              • 5532
              • 251 Posts
              Creating 2 AjaxSearch snippets using the above instructions doesn’t work - obviously some sort of javascript conflict somewhere.

              Does anyone know if you can have 2 Ajax Search boxes on the same page?
                • 34001
                • 428 Posts
                Hi,
                Quote from: cms at Jan 20, 2010, 09:42 AM

                Does anyone know if you can have 2 Ajax Search boxes on the same page?
                It’s now possible with the last beta version: http://modxcms.com/forums/index.php/topic,44365.0.html
                  Intégrateur web freelance
                  • 5532
                  • 251 Posts
                  Thanks! Have just seen that on the AjaxSearch forum.

                  Cheers