We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26027
    • 145 Posts
    We are using MODx Evolution 1.04 with Ditto 2.1.0.

    Our pages have a sidebar or sidebox design where up to 4 sideboxes can be displayed. You can see the specific page(s) that are causing us trouble at: http://www.edlawcenter.org/news/archives.html but first I should tell you our problem.

    There are 10 menu links on this page that all present the same two sideboxes (as shown on right of the page). Intermittently, seemingly at random, several of these 10 linked pages will be devoid of their two side boxes. Generally around 4 or 5 will be missing their sideboxes and the others will have them. In every case the problem is easily fixed temporarily by logging into manager and clearing the cache. I've also found that if I edit and save any of the 10 pages, that also seems to fix the problem temporarily. I'm pretty weak with MODx CMS but my suspicion is that Ditto may be at fault. Here's the code from one of two templates that presents these sideboxes:

    {{tpl_header}}
    	<div id="threecolumns"><!-- "twocolumns" -->
            
     	<div id="subnav3rd">
     [[Wayfinder?startId=`[*parent*]` &displayStart=`true` &startItemTpl=`ms.StartItemSub` &outerTpl=`ms.OuterTpl` &rowTpl=`ms.RowTpl` &firstClass=`first` &hereClass=`current` &selfClass=`here` &rowIdPrefix=`sm`  &sortBy=`menuindex` &sortOrder=`asc` ]]
    		</div>
    		
           <div id="sidecontent">
    [[Ditto? &documents=`[*SideBox1*]` &total=`1` &tpl=`crossBoxChunk` &sortDir=`` &noResults=` `]]
    [[Ditto? &documents=`[*SideBox2*]` &total=`1` &tpl=`crossBoxChunkAnchor` &sortDir=`` &noResults=` `]]
    [[Ditto? &documents=`[*SideBox3*]` &total=`1` &tpl=`crossBoxChunk` &sortDir=`` &noResults=` `]]
    [[Ditto? &documents=`[*SideBox4*]` &total=`1` &tpl=`crossBoxChunk` &sortDir=`` &noResults=` `]]
           </div>
            
            <div id="content">
    		<h1>[*pagetitle*]</h1>
             [*content*]
    <p class="pagination"><strong>[+previous+]</strong>  |  Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles on Page <strong>[+currentPage+]</strong> of <strong>[+totalPages+]</strong>  |  <strong>[+next+]</strong></p>
    		</div>
            
    	</div>
    
    {{tpl_footer}}


    Is this enough information for any of you to suggest where I might look to find the culprit here?

    One additional thing I might tell you now which may or may not help is that the line above (<div id="sidecontent">) is always present when the sideboxes are missing which is why I suspect Ditto.

    Thanks very much to anyone who may be able to help.

    --- Sam (Gerber)
      • 19369
      • 1,098 Posts
      You may need to use Ditto Uncached, so change it from this:
      [[Ditto]]

      to this:
      [!Ditto!]

      Example:
      {{tpl_header}}
          <div id="threecolumns"><!-- "twocolumns" -->
               
          <div id="subnav3rd">
       [[Wayfinder?startId=`[*parent*]` &displayStart=`true` &startItemTpl=`ms.StartItemSub` &outerTpl=`ms.OuterTpl` &rowTpl=`ms.RowTpl` &firstClass=`first` &hereClass=`current` &selfClass=`here` &rowIdPrefix=`sm`  &sortBy=`menuindex` &sortOrder=`asc` ]]
              </div>
               
             <div id="sidecontent">
      [!Ditto? &documents=`[*SideBox1*]` &total=`1` &tpl=`crossBoxChunk` &sortDir=`` &noResults=` `!]
      [!Ditto? &documents=`[*SideBox2*]` &total=`1` &tpl=`crossBoxChunkAnchor` &sortDir=`` &noResults=` `!]
      [!Ditto? &documents=`[*SideBox3*]` &total=`1` &tpl=`crossBoxChunk` &sortDir=`` &noResults=` `!]
      [!Ditto? &documents=`[*SideBox4*]` &total=`1` &tpl=`crossBoxChunk` &sortDir=`` &noResults=` `!]
             </div>
               
              <div id="content">
              <h1>[*pagetitle*]</h1>
               [*content*]
      <p class="pagination"><strong>[+previous+]</strong>  |  Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles on Page <strong>[+currentPage+]</strong> of <strong>[+totalPages+]</strong>  |  <strong>[+next+]</strong></p>
              </div>
               
          </div>
       
      {{tpl_footer}}
        • 26027
        • 145 Posts
        microcipcip, thanks for your reply. I don't understand the difference between running Ditto cached vs. uncached and don't know how that relates to the entire page being cached.

        Are you thinking that for 'reasons unknown' the Sidebox documents were disappearing from the cache where Ditto was expecting to find them and this will force Ditto to ignore cache considerations? Is such behavior somewhat common or could there be something else lurking here? Please don't take offense but I guess I'm trying to assess the probability your solution will work for me.

        Regardless, it can't break anything can it? My intuition say it will run fine, albeit a few nanosecs slower by not caching.

        ??? Sam
          • 26027
          • 145 Posts
          microcipcip, while I was waiting for your response I tried your suggestion. One of the sideboxes (template variable) contains an eForm coded as:

          [!eForm? &formid=`JoinOurNetworkForm` &subject=`Request from ELC Join Our Network Form` &from=`[email protected]` &to=`[email protected]` &ccsender=`0` &tpl=`join_our_network` &report=`join_our_network_report` &automessage=`join_our_network_thanks` &eformOnValidate=`checkField` !]


          Turns out that if Ditto is uncached and eForm is uncached, eForm will not work. Same is true is Ditto and eForm are both cached. If Ditto and eForm are cached opposite to each other then that combination works.

          Does this make any sense at all to you? I could uncache Ditto and cache eForm and it seems to work, but that's not the way the developer set it up and therefore I'm putting myself at some risk making this type of change.

          Sorry to burden you with this happiness. If you don't write back I'll understand.

          --- Sam
            • 19369
            • 1,098 Posts
            Hi, sorry for the late reply.

            Basically, if you cache a snippet it means that the code will change only if you clear the website cache (or if you save a page, which means the cache of that page will be cleared). If you use a snippet uncached the code will upgrade every time you open the page in the browser, regardless if the content has changed or not. This can slow down the website, but if you're not calling many pages it shouldn't matter too much.

            Sometimes you may find that a snippet inside another snippet may not work, like having a snippet cached inside another uncached or something similar. You should "play" with them and see how to get them to work. Usually try to make the "heavier" snippet cached, because otherwise that may slow down a (big) website. [ed. note: microcipcip last edited this post 13 years, 6 months ago.]
              • 26027
              • 145 Posts
              Let me run this by you. All four of the sideboxes are Template variables. They are processed by Ditto, as we discussed, and you showed me how to make Ditto run uncached.

              However, all the sideboxes are document resources without templates and appear in the resource tree and as such they are all coded with the 'cacheable' setting. What if I made these sideboxes 'uncacheable' by unchecking the checkbox. Will MODx ignore the 'cacheable' setting in favor of the [[ ]], [! !] syntax or will it honor the setting? If it honors it then all the sideboxes become 'uncacheable' and should therefore be retrieved anew every time a page with Ditto calls in its template executes against these sideboxes.

              [NOTE: Of course this still begs the question of why do the sideboxes disappear intermittently, but I'm not sure I care about that any longer.]

              Am I falling victim to a bug in MODx, microcipcip, by following my intuition on this?

              Thanks ... Sam
                • 19369
                • 1,098 Posts
                I don't think that making the sideboxes uncached will change anything.

                I am noticing now that you are using Ditto to just output one page of content.
                You can accomplish the same with other snippets (getField for example), or even with chunks. Why do you need Ditto there? Just because you need the content editable by the user?

                Also, what's the content of [*SideBox1*],[*SideBox2*],[*SideBox3*],[*SideBox4*]? I know, it is an id, but do you need it to be different in every page?
                  • 26027
                  • 145 Posts
                  I'm going to try to answer your questions as well as I can. You have me somewhat over my head to a degree. You asked why do I need Ditto and that cannot be answered. The developer made that decision and that company is no longer available.

                  You asked about the content of the 4 sideboxes. They are Template Variables and contain near identical coding. I've attached the coding, if you call that coding. All for sideboxes are 100% identical except for the 'sort order' which varies from 20 to 23 for the 4 variables.

                  3 different higher level templates use up to 4 sideboxes. The actual content of the sidebox can vary. For example the template for the following page http://staging.edlawcenter.org/issues/preschool.html refers to the 'Join Our Network' sidebar item as 'Sidebox3', whereas the template for http://staging.edlawcenter.org/news/archives.html refers to it as 'Sidebox2'.

                  The content of the resource id called 'Join Our Network' is shown in the 2nd attachment. It simply contains the eForm specifications.

                  I don't know if this information is helpful to you but I am over my head, as stated earlier, and I'm being careful not to mislead you. It's too bad the developer bailed on me but that's the way it is. I do the best I can and usually that's good enough, microcipcip, although you may be disappointed.

                  Later ... Sam [ed. note: samg last edited this post 13 years, 6 months ago.]
                    • 19369
                    • 1,098 Posts
                    Quote from: samg at Apr 17, 2013, 08:34 PM
                    3 different higher level templates use up to 4 sideboxes. The actual content of the sidebox can vary. For example the template for the following page http://staging.edlawcenter.org/issues/preschool.html refers to the 'Join Our Network' sidebar item as 'Sidebox3', whereas the template for http://staging.edlawcenter.org/news/archives.html refers to it as 'Sidebox2'.

                    The content of the resource id called 'Join Our Network' is shown in the 2nd attachment. It simply contains the eForm specifications.

                    So, if I understand correctly, the TV show a dropdown menu with the 4 sideboxes, and you choose the order of each one. If you do not choose one, it will be set to 0 and therefore it will not show up in the website. I belive that this could be accomplished in another way, for example, you could do as follow:
                    1. Change each TV as follow:
                    TV name: SideBox1
                    Caption: Side Box 1
                    Input Type: DropDown List Menu
                    Input Option Values: Select a value == ||SideBox1 == {{SideBox1}}||SideBox2 == {{SideBox2}}||SideBox3 == {{SideBox3}}||SideBox4 == {{SideBox4}}

                    2. Call them in the template, for example in this way:
                           <div id="sidecontent">
                               [*SideBox1*]
                               [*SideBox2*]
                               [*SideBox3*]
                               [*SideBox4*]
                           </div>

                    3. Create the 4 chunks with the proper content for each one.

                    Note: if a section of the website has always (or almost) the same sidebar (for example box2,box3), you may be able to set up them from the containing folder, for example from "issues" or "news" by selecting TV Input Type: text, and TV Default Value: @INHERIT, as this would make all the children resources @INHERIT the value of the parent folder. But maybe to accomplish this you may have to change quite a bit the structure of the website.
                      • 26027
                      • 145 Posts
                      microcipcip, I'm not grasping the path you're leading me down.

                      What is step 1 above actually doing?

                      Step 2 has eliminated Ditto. Is that the main point behind your steps 1 and 2?

                      Finally, in step 3 you've asked me to create 4 chunks with content. I have no clue what should be in the 4 chunks, how they're called, and how they correspond to the Sideboxes 1-4.

                      In the previous code that you're having me replace, I didn't have a good understanding of how that worked. It took a combination of a calling template which contained a Ditto call which in turn referenced a template variable AND a chunk, and that chunk retrieved content. My skill level with MODx is nowhere near understanding how to piece together so many disparate parts and make them work together.

                      Honestly I'm not even sure how templates, chunks, snippets and resource ids are different from one another. I often see them serving the same purpose in terms of bringing content to the the page. Example, the Ditto call references a "tpl" which to me should be a template and yet it's a "chunk". I've also seen "snippet" and "chunk" used interchangeably. MODx jargon can be very confusing, especially for a newbie.

                      If you want to give up on me, here's your chance and I'll thank you for traveling this far on what is likely becoming a painful trip you didn't bargain for.

                      ??? Sam