We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6102
    • 17 Posts
    I would like for Newslisting to return a result of LongTitle and the first 120 characters of the summary and/or the content if the summary is blank (or less than 120 characters.)

    Example

    Long Title 1 Here
    Blog entries are simply pages in the document
    tree in MODx. Use...  More on this story

    Long Title 2 Here
    Blog entries are simply pages in the document
    tree in MODx. Use...  More on this story

    Long Title 3 Here
    Blog entries are simply pages in the document
    tree in MODx. Use...  More on this story

    Thank you for your help!

    Kevin
      • 15159
      • 93 Posts
      At’s ok folks. I leaned over and showed him the &truncLen function. smiley Good thing we work next to each other... But he is Good. Oh very good. (he is the boss...)
        • 18397
        • 3,250 Posts
        Please follow these instructions:

        Creating a new template:
        To create your own templates you will need to have some knowledge of how html works.

        Create a chunk based on following code and note its name. This document will assume you named it NewsListingTemplate.

        Default display template (tpl):
        <div class="nl_summaryPost">
        <h3><a href="[~[+id+]~]">[+title+]</a></h3>
        <div>[+summary+]</div>
        <p>[+link+]</p>
        <div style="text-align:right;">by <strong>[+author+]</strong> on [+date+]</div>
        </div>


        Available placeholders
        Any document object (list) in the format of [+documentobject+]
        Any template variable in the format of [+tvnameoftv+]
        [+next+] - next button
        [+previous+] - previous button
        [+prevnextsplitter+] - splitter if always show is 0
        [+pages+] - page list
        [+totalpages+] - total number of pages
        [+start+] - the # of the first item shown
        [+stop+] - the # of the last item shown
        [+total+] - the total # of items
        Append
        &tpl=`NewsListingTemplate`

        to your snippet call and NewsListing will use your custom template
          • 6726
          • 7,075 Posts
          Thanks Mark for the instruction, certainly something to bookmark as part of a NewsListing tutorial smiley
            .: COO - Commerce Guys - Community Driven Innovation :.


            MODx est l&#39;outil id
            • 18397
            • 3,250 Posts
            That was actually copied and pasted from my documentation article on modxcms.com (Documentation >> Core Snippets >> NewsListing)
              • 6726
              • 7,075 Posts
              dumb me, thanks for the clarification... should check the doc more often !
                .: COO - Commerce Guys - Community Driven Innovation :.


                MODx est l&#39;outil id
                • 32847
                • 171 Posts
                the first 120 characters of the summary and/or the content if the summary is blank

                is there a way to do that cause Mark answer is ok only with a summary, isn’t it?
                  • 18397
                  • 3,250 Posts
                  Huh?
                    • 6102
                    • 17 Posts

                    I figured out how to do this by following the more detailed instructions found in the snippit itself.

                    Use the following snippet call:

                    [[NewsListing? &tpl=`NewsListingTemplate` &startID=`2` &truncLen=`120` &truncText=`More...`&pubOnly=`true` &sortby=`pub_date` &summarize=`8` &trunc=`true`]]

                    The &truncLen=`120` does the trick.

                    With my css, NewsListingTemplate and this call I get a result that looks like this:

                    Editing Blogs and Comments
                    by siteadmin on 14-Oct-05 15:38
                    Blog entries are simply pages in the document tree
                    in MODx. User Comments for an article are... More...

                    Thanks everyone.
                      • 32847
                      • 171 Posts
                      I realised I used [+introtext+] in my chunk rather than [+summary+] but it’s a wrong way when introtext is empty. That the reason why I missed something grin