We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10573
    • 101 Posts
    I have a list of dance descriptions in a folder each dance is in a separate document.

    FOLDER
    - dance description 1
    - dance description 2
    - dance description 3

    The documents are not listed in the menu.

    I’d like to list the dance descriptions on a page in alphabetical order. Would I use ditto for this? As of right now, it sorts it by date. I want to list them alphabetically by document name.

    Thanks for your help!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      &sortby=`pagetitle` should do the job.
        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
        • 10573
        • 101 Posts
        Thanks for the quick reply.

        At first i thought it wasn’t working, but it is case sensitive. it should be sortBy.

        If ditto can sortBy "anything"

        I’m assuming it can sort by anything in the site_content table?
        For example:
        id
        type
        contentType
        pagetitle
        longtitle
        description
        alias
        link_attributes
        published
        pub_date
        unpub_date
        parent
        isfolder
        introtext
        content
        richtext
        template
        menuindex
        searchable
        ccheable
        createdby
        createdon
        editedby
        editedon
        deleted
        deletedon
        deletedby
        publishedon
        publishedby
        menutitle
        donthit
        haskeywords
        hasmetatags
        privateweb
        privatemgr
        content_dispo
        hidemenu

        If so, this should be documented in more detail.
          • 8790
          • 526 Posts
          yep

          I was crawling with the same question.. probably alway evident for devs

          but I still can’t truncate my ditto results, undecided even copying some code found in the forum..(even &summarize ..don’t summarize)

          But, also, did you understood what is the &tpl param ?

          I still do not see what it is supposed to contain. huh

          The test I’m doing to learn Ditto is done with a testpage using a specific page tpl (only difference with general tpl it’s calling a chunk where the Ditto code is inserted). So I do not see what is &tpl. (or precisely what it’s supposed to do)

          If some could clarify..

          Thank you
            Schtroumpf Grognon - Grouchy Smurf
            ---------------------------------
            Faites pas attention.. - Don't pay attention
            http://www.dzi-neo.net
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            &tpl is the chunk used as a template to display the entire summary block. It is applied to each summary as Ditto loops through the documents to summarize.

            $summarize is for how many documents to summarize. The default is 3.

            There are seven options that control the truncation of the summary:
            $trunc = isset($trunc) ? $trunc : 1;
                // should there be summary/short version of the posts?
            
            $truncSplit = isset($truncSplit) ? $truncSplit : 1;
                // should the post be summarized at the "splitter"?
            
            $truncAt = isset($truncAt) ? $truncAt : $_lang['default_splitter'];
                // where to split the text
            
            $truncLen = isset($truncLen) ? $truncLen : 300;
                // how many characters to show of blogs
            
            $truncOffset = isset($truncOffset) ? $truncOffset : 30;
                // how many characters to show of blogs
            
            $truncText = isset($truncText)? $truncText : $_lang['more_text'];
                // text to be displayed in item link
            
            $truncChars = isset($truncChars) ? $truncChars : 0;
            	// truncate based on characters and not html tags
            


            Ditto will first look for whether or not to have a summary text at all.

            Then it will look for a "splitter" in the document’s content, and display the document’s content up to that splitter (by default, that is something like <!-- splitter --> ).

            If it doesn’t find a splitter, then it will use the document’s Summary (introtext) field instead of the contents.

            If there is nothing in the Summary (introtext) field, then it will use the character count to truncate the document’s content. The truncOffset will let you specify how many characters into the document’s content to start displaying (to skip over an image tag, for example). If the post is shorter than the character count (either as specified in the snippet call, or the default of 300 characters) it displays the entire contents of the document.
              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
              • 8790
              • 526 Posts
              thank you very much, it become clearer

              &tpl is the chunk used as a template to display the entire summary block.

              why should we use à chunk..no I mean Is this a MUST ? So this chunk should inly contains whatever I want to display the result of Ditto ..right ? If I put Ditto’call directly into the main page tpl, with no &tpl is this ok too ?

              ...it will use the document’s Summary (introtext) field

              ?? so people have to fill this when creating a new page ?! woh this default way of working should concern 0.1% of the need isn’it ?

              character count to truncate the document’s content.

              Look like I was doing right..

              The truncOffset will let you specify how many characters into the document’s content to start displaying (to skip over an image tag, for example)

              Do you mean it looks INTO THE HTML !???! and not into the real content huh! but this is absolutely nut ?!

              I cant believe.
              is this the response :
              $truncChars = isset($truncChars) ? $truncChars : 0;
              	// truncate based on characters and not html tags


              humm. I do not know yet what is isset stuff.

                Schtroumpf Grognon - Grouchy Smurf
                ---------------------------------
                Faites pas attention.. - Don&#39;t pay attention
                http://www.dzi-neo.net
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                If you don’t specify a $tpl, then Ditto will use the default template. You can find it (at least in the latest version) in the lang file, around line 16:
                $_lang['default_template'] = '
                    <div class="ditto_summaryPost">
                        <h3><a href="[~[+id+]~]">[+title+]</a></h3>
                        <div>[+summary+]</div>
                        <p>[+link+]</p>
                        <div style="text-align:right;">by <strong>[+author+]</strong> on [+date+]</div>
                    </div>
                ';
                


                If you don’t choose to put something in the "Summary" (introtext) field, then Ditto will just take the first xxx characters from the content.

                That’s right, Ditto works directly on the raw content. Think about it...what else would it work on? The document content can contain HTML code and MODx tags. And how else will it find the HTML comment <!-- splitter --> if that is how you want the content truncated?

                isset() checks to see that the variable has been set, that it actually exists. It may have a value such as "myValue" or "23" or even an empty string "". It’s always a good idea to check on that, since PHP throws ugly warning messages if you refer to a variable that was never set.
                  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
                  • 8790
                  • 526 Posts
                  If you don’t specify a $tpl, then Ditto will use the default template. You can find it (at least in the latest version)

                  ok I see better,

                  ...HTML comment <!-- splitter -->
                  Very unusual way.. it’s suppose people will write their article dealing with this marker. No really applicable in real life. And first cms I c doing this (but I didnt see so many cms anyway). Always useful, but not for majority.

                  Also, from a page to another, nobody can tell where will be the first human significant caracter. So how to decide where is the limit ?

                  As we’re supposed to work properly with as clean as possible XHTL and CSS, the truncate function should works taking in count only content of Hn and P, and may be some other tag contains. (ideally another parameter could exist to take, or not, in count pure html or only resulting displayed text and pix).
                  The main purpose of such a function, is to generate automatic summary (ie site pan, news bloks and so on) and, yes, many other stuff.

                  I see on your site here :http://www.sottwell.com/articles.html, after a peek to your {{ditto_articles}}
                  you use the summary, but ... who wanna write a static summary when computer could extract the beginning of the article (I mean should do it). Imaging you change totally one article (ok I dont know why you could do this) then you’re supposed to deal again with summary field.. really a pain.

                  In your article page you directly put the ditto’s call into the page content.
                  Is this possible if just call into the page’s tpl code ? (cause actually, nothing occurs in my test if done like this) ?

                  Thank you for your very helpful advises and answer.

                  Regards,
                    Schtroumpf Grognon - Grouchy Smurf
                    ---------------------------------
                    Faites pas attention.. - Don&#39;t pay attention
                    http://www.dzi-neo.net
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    That’s pretty much what it does; it’s coded to skip over the tags and only count the actual display text. But it will keep the html tags as-is, including allowing for (for example) an opening <p> tag, then the max characters without encountering the closing </p> tags, it will automatically generate the appropriate closing tag. I was being brief.

                    As far as the introtext goes, I tend to use it a lot anyway, placing it in a box in the main content, or in a sidebar with special formatting. It’s not necessary to use it, but it’s handy sometimes. MODx aims to be as flexible as possible, without requiring you to follow any particular format or procedure beyond the bare minimum.
                      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
                      • 12652
                      • 228 Posts
                      Actually, I think using some form of HTML comment is used on a lot of the CMS’s... I know Drupal does this, <!--break--> if I remember correctly, and I was thinking Joomla did as well. Most people probably won’t use it, but it does give a finer control and a little more power.
                        | Identity Developments delivers SEO focused web design and web presence services
                        - it&#39;s not about websites, it&#39;s about your identity. |