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

    Can anyone explain how to display only the first few lines of document and make the entire article available via a "read more" link ? Also how can multiple documents featuring the read more links as created in my initial question be displayed on the front page in a blog style?

    Thanks
      • 5340
      • 1,624 Posts
      Use Ditto in combination with PHx
      Documentation: http://modxcms.com/forums/index.php/topic,13533.0.html
        • 3749
        • 24,544 Posts
        You can also do it without phx by putting the teaser in the summary field of the document and just showing that as a link to the full article.

        Here’s one I did like that:

        [!Ditto?startID=`8` &display=`3` &dateFormat=`%d-%b-%y %I:%M %p` &tpl=`MyNewsItemChunk` &extenders=`summary` !] 


        All the news articles are children of document 8 in my case. And I just created a chunk called MyNewsItemChunk containing the following:

        <item>
           <div class="ditto_summaryPost">
              <h3>[+title+]</h3>
              <div class="ditto_summary">[+summary+]</div>
              <div class="seemore"> <a href="[~[+id+]~]" title="[+title+]">See more about this story . . .</a> </div>
              <div class="postedby">» Posted by [+author+] on [+date+]</div>
          
        </div>
        <hr/>
        </item>


        I did it this way instead of using phx because I wanted to chose the length of the teaser myself rather than having an arbitrary cutoff point.

        BTW, if you’re using Ditto 2.x, you’ll have to change &startID to &parents.

        Hope this helps.
          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
          • 3749
          • 24,544 Posts
          Oops. The example I gave only works with friendly URLs on. It’s from an early MODx site of mine and the [+id+] is incorrect. It should be [~[+id+]~]. I’ve corrected it in the post above.
            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
            • 7231
            • 4,205 Posts
            Don’t forget the Summary extender for Ditto. You can set a trucate limit and use the [+summary+] placeholder.
            http://ditto.modxcms.com/files/assets/snippets/ditto/extenders/summary-extender-inc-php.html
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 13712
              • 15 Posts
              Cheers fellers, between the two suggestions I should be able to sort things out smiley. I am especially impressed with BobRays example though. I am still learning the ins and outs of Modx but I think I am just about able to make sense of the supplied code. There are some parts I can need to be clarified:

              1. &display=`3`, is this is number of viewable opening lines (teaser) of the article?
              2. Those three css classes in the Chunk "ditto_summary", "seemore" and "postedby" where have they been defined? Are they part of Ditto or do I have to create them in my template’s css file use them in the template?

              Regarding my second question (displaying several article opening lines plus "read more" on the front page in blog format), I did not see any reference to it in the responses. Is there a solution to this in the Ditto documentation?

              Thanks once again

                • 4310
                • 2,310 Posts
                &display=`3`
                Refers to how many documents to summarise.
                  • 13712
                  • 15 Posts
                  Cheers David smiley.
                    • 3749
                    • 24,544 Posts
                    Quote from: jazzy at Jan 31, 2009, 05:56 AM

                    Cheers fellers, between the two suggestions I should be able to sort things out smiley. I am especially impressed with BobRays example though. I am still learning the ins and outs of Modx but I think I am just about able to make sense of the supplied code. There are some parts I can need to be clarified:

                    2. Those three css classes in the Chunk "ditto_summary", "seemore" and "postedby" where have they been defined? Are they part of Ditto or do I have to create them in my template’s css file use them in the template?

                    Regarding my second question (displaying several article opening lines plus "read more" on the front page in blog format), I did not see any reference to it in the responses. Is there a solution to this in the Ditto documentation?

                    I defined those three classes in the site CSS file:

                    div.ditto_summaryPost {
                    	color:#ffffff;
                    	font-family:"Times New Roman", Times, serif;
                    	font-size:12px;
                    	margin-bottom:0px;
                    	font-weight:bold;
                    
                    padding:5px 30px 5px 30px;
                    	
                    }
                    div.ditto_summaryPost a:hover {
                    color:#000000;
                    background-color:#bbbbbb;
                    }
                    div.ditto_summary {
                    color:#000000;
                    font-family:"Times New Roman", Times, serif;
                    font-size:16px;
                    font-weight:normal;
                    }
                    
                    div.ditto_summaryPost h3 {
                    	text-decoration:none;
                    	text-transform:uppercase;
                    	font-size:14px;
                    	color:#336699;
                    }
                    div.postedby {
                    	font-family:Arial, Helvetica, sans-serif;
                    	color:#000000;
                    }
                    div.ditto_summaryPost ul {
                    
                    padding-left:0px;
                    margin-left:0px;
                    list-style-image: url(bullet.gif);
                    list-style-type:none;
                    list-style-position:outside;
                    margin-bottom:5px;
                    
                    
                    
                    }
                    div.seemore {
                    	margin-top:0px;
                    	padding-top:0px;
                    	margin-bottom:10px;
                    	text-align:right;
                    	font-style:italic;
                    	color:#000066;
                    }


                    Just set the $display parameter to the number of articles you want to show and the rest should be automatic.
                      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