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

    I need a little help.

    I need a list of some articles, with their longtitle - but I need to limit the title to about 30 characters, and if the limit is over, show "..." on the end.

    It should look like this:

    02/05 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
    01/05 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...

    (Instead of the rest of "aaa" - after the 30th character - there is ... )

    Is it possible?

    I use DItto to make the list and a template that looks like this:
    <li>([+date+])<a href="/[~[+id+]~]">[+longtitle+]</a></li>

    The ditto part looks like this (I use a filtering by tags):
    <ul>
    [!Ditto? &dateFormat=`%m/%d` &parents=`264,223,226,283`  &dateSource=`pub_date` &filter=`tag,1,7` &display=`all` &noResults=`no_post` &tpl=`tag_list` &depth=`0` ;!]
    </ul>
      • 33337
      • 3,975 Posts
      With the help of these:

      http://wiki.modxcms.com/index.php/PHx#length_.7C_len
      http://wiki.modxcms.com/index.php/PHx/CustomModifiers#phx:character_limit

      <li>([+date+])<a href="/[~[+id+]~]">[+longtitle:if=`[+longtitle:len+]`:gt=`30`:then=`[+longtitle:character_limit=`30`+] ...`:else=`[+longtitle+]`+]</a></li>
      
        Zaigham R - MODX Professional | Skype | Email | Twitter

        Digging the interwebs for #MODX gems and bringing it to you. modx.link
        • 15136
        • 34 Posts
        Quote from: zi at Mar 16, 2009, 04:48 AM

        With the help of these:

        http://wiki.modxcms.com/index.php/PHx#length_.7C_len
        http://wiki.modxcms.com/index.php/PHx/CustomModifiers#phx:character_limit

        <li>([+date+])<a href="/[~[+id+]~]">[+longtitle:if=`[+longtitle:len+]`:gt=`30`:then=`[+longtitle:character_limit=`30`+] ...`:else=`[+longtitle+]`+]</a></li>
        


        Almost Everything works including the check for the length of the title. However this part

        then=`[+longtitle:character_limit=`30`+] ...`

        Does not work, it does not show anything, it is just whitespace. Any advice?

        A few notes, longtitle is populated with data and i was debugging and tried [+longtitle+] and it printed out just fine. Not sure if my syntax is wrong but i’m using the code that the previous person entered.
          2.2.4 Revolution
          • 20349 ☆ A M B ☆
          • 453 Posts
          You can always try

          [+title:limit=`50`+]


          Hope it helps wink
            BASE - Web Design Studio
            MODX Ambassador

            Website