We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10405
    • 288 Posts
    Hopefully my last Ditto problem for a while! I’m setting up some basic "teaser text" previewing blog articles, on a site home page. It’s almost there but for some reason my Ditto template formatting is being overwritten by the formatting of the article itself.

    Here’s the Ditto call being made on the home page:

    [!Ditto? &parents=`10` &depth=`0` &filter=`id,12,2|id,13,2|id,14,2|id,15,2|id,16,2|id,19,2` &tpl=`ditto.homepageblogpreview` &total=`1` &extenders=`summary` &truncLen=`100` &truncText=`Read More`!] 
    


    And this is my Ditto template:

    <a href="[~[+id+]~]"><p><strong>[+title+]</strong></p></a><p>[+summary+]</p> <a href="[~[+id+]~]">Read more</a>
    


    The problem seems to be that the [+summary+] is showing the first four words in very large text, the same formatting as is used on the actual article page. I want it to just use normal paragraph text- but it won’t accept it. I even tried:
     <p style="font-size:10px;">
    to no avail...


    On another note, I want to place two separate teaser text blocks on the home page, for the two most recently published articles, but not sure how to make the call pick up the second most reently-published article for the second teaser text block...
      • 10405
      • 288 Posts
      I’ve managed to reduce the text size, although I had to explicitly create CSS for it in the home page template- messy!

      However the problem now is that the blog title first appears (great) but then the document title from inside the <h1> in the resource / blog content, followed by the paragraph text.

      It doesn’t really make sense for both the resource title and the <h1> title from inside the content to appear together, so is there a way I can specially truncate / snip the <h1> title out and start the output for the teaser text only at the start of the first <p>??
        • 10405
        • 288 Posts
        Anyone know if this can be done?

        Also how can I automatically output the teaser text for not just the most recently-published article but the second most recfently published? (As they both need to be displayed)

          • 28042 ☆ A M B ☆
          • 24,524 Posts
          It’s all in your CSS. The teaser content is getting its styling from your main content css. Your teaser should be in a container, like <div id="teaser">[[Ditto? ...]]</div>

          Then in your CSS you can specify
          #teaser p {}
          #teaser h1 {}
          etc...
          


          Your main page heading (usually the H1 tag) shouldn’t be in the resource content, anyway. It should be the longtitle, and should be in the template:
          <h1>[*longtitle*]</h1>
          [*content*]

          That way it won’t get sucked up into the Ditto [+content+] placeholder.
            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
            • 10405
            • 288 Posts
            Thanks, that seems to work pretty well and it’s less formatting that the user has to grapple with.

            Only thing now is I need to create another teaser text block but outputting the second-most recently published article- still not sure how I can do that...
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Doesn’t Ditto have an offset parameter? &start or something like that...
                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
                • 10405
                • 288 Posts
                Thanks- seems to work if I use &start=`1` for the second teaser text box, so skipping the most recently-published resource, so that should be ok.