We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24495
    • 407 Posts
    Hi specialists, I’m not so skilled in php and a newb in modx. My Problem:
    In my news articles I have

    • the content for the full article
    • a tv "teasertxt" for a short teaser with custom text different as the full article
    Now I use ditto with custom tpl to list all news in an overview page. Some articles don’t need the content because they are only a short news on overview without a link to a full article.

    How can I create tpl chunk/additional snippets to make this:

    • If content is empty: show teasertxt
    • if content AND teasertxt not empty: show teasertxt
    • if content is not empty AND teasertxt is empty: show content

    Any suggestions? thanks, Rainer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Ditto can use the document’s "summary" (introtext) as the default "teaser" text. Have you tried using 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
        • 24495
        • 407 Posts
        It’s difficult, because I want to build fully accessible pages (wcag, 508). Therefor I must have capabilities to set acronyms, lang-attr and so on. The summary isn’t flexible enough. That’s why I use a custom tv for teaser text. (Don’t know wether the introtext can have html? Otherwise this field is a bit too small to handle larger input.)
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          I use the summary field like this for a real estate listing page:
          <a href="[~55~]"><img src="assets/images/listings/house.jpg" alt="address of house" width="300" height="250" /></a><p>Op een mooie hoek locatie in een rustige woonwijk staat deze grote half vrijstaande woning met garage en tuin op een ruime kavel van 358 m²</p>

          So not only can you use HTML, you can also use MODx tags in the summary field.
            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
            • 24495
            • 407 Posts
            Use of HTML in summary was new knowlegde for me. Thanks for this, I’ll try it