We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21112
    • 156 Posts
    I am using Ditto to display a list of links to articles and I want to use &extenders=`summary` to generate a summary of the article. I do not wish to use introtextbecause this site will be handed over to clients who are unfamiliar with HTML and CMSes, and I want them to fill out as few fields as possible when adding new articles. By using summary, it will be generated automatically, rather than having to count and copy the first x number of characters from the article into introtext.

    The problem I am having with summary is that the code generated by ditto surrounds the summary with a <p> tag. This is fine, but the [+link+] is inserted in the code after the </p> tag and thust forced onto the next line. I want the "Read more" link to be on the same line as the summary. If I put text into the introtext field, the code ditto generates does NOT surround this text with a <p> (which in itself is poor form for semantic html), ad as such renders the Read more link on the same line.

    Is there any way to cause the </p> tag to be rendered *after* the [+link+]?

    Thanks in advance for the help. If you need to see any of my code, just let me know and I can share it here.
      • 18397
      • 3,250 Posts
      Ditto does not wrap the summary nor the introtext in a p tag. All formatting is up to the user in his or her template. What is most likely happening here is you are using TinyMCE or another RTE. These editors have a tendency to wrap the content your write in a p tag. Check the content of your page to make sure it is not wrapped in p tags.
        • 21112
        • 156 Posts
        Of course, I thought that may have been the source of the <p> but forgot about thatw hen I posted.

        I edit in HTML, but I surround all paragraphs in <p> tags, so that I can format the text and also just for good HTML syntax. I guess I assumed that Ditto would strip the HTML for the summary. Is there no way then, that I can keep my text content marked up with tags and still have the "Read more" link on the same line as the summary?

        Incidentally, one thing that confused me and made me thing it was Ditto putting the <p> tag in, was that there is a closing tag at the end of the summary. Even though I have set a character limit to the summary, and usually the summary doesn’t end exactly at the end of the </p> tag, the summary is always closed. How does this happen and would it be a possibly way to work in the [+link+] before the </p>?
          • 18397
          • 3,250 Posts
          Quote from: neilcreek at Apr 30, 2007, 10:55 PM
          Even though I have set a character limit to the summary, and usually the summary doesn’t end exactly at the end of the </p> tag, the summary is always closed. How does this happen ...
          The summary extender has a tag completion function so if truncation would cutoff an important end-tag (such as the p) it will close it to keep the page valid.

          Quote from: neilcreek at Apr 30, 2007, 10:55 PM

          I assumed that Ditto would strip the HTML for the summary .... Is there no way then, that I can keep my text content marked up with tags and still have the "Read more" link on the same line as the summary?
          This is possible with a few modifications to the summary extender. You would need to take the $summary variable and just before the closing tag insert the [+link+] placeholder via PHP. Something like the following.
          Find:
          return $summary;
          

          Replace with:
          $summary = strip_tags($summary); // removes all tags
          $summary = '<p>'.$summary.'[+link+]</p>';
          return $summary;
          
            • 21112
            • 156 Posts
            Brilliant! That did exactly what I need. Thanks so much for the help!