We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13226
    • 953 Posts
    Hi to all,

    I am currently re-building a website which doesnt use the default "content" box when creating a new page.

    I have created a variety of TemplateVariables which are for specific content and one of those has the description of the element.

    I would like to add the content from this TemplateVariable as the description for the RSS feed.

    Question 1:
    Is it possible to add a specific TV instead of [+summary+] or [+content+]

    Question 2:
    Is it possible to truncate the content e.g max. 255 characters and remove HTML tags from the TV’s output

    I have used the tutorial shown on the Ditto subdomain - Custom RSS Feed to create a chunk for the RSS output (rss_item), but havent been able to figure out how to get around my problem.

    RSS Item Chunk
    <item>
      <title>[+rss_pagetitle+]</title>
      <link>[(site_url)][~[+id+]~]</link>
      <description>
        <![CDATA[ <p>[+MYTVCONTENT+]</p> ]]>
      </description>
      <pubDate>[+rss_date+]</pubDate>
      <guid isPermaLink="false">[(site_url)][~[+id+]~]</guid>
    </item>
    


    My Ditto Call:
    [[Ditto? &parents=`15` &format=`rss` &summarize=`30` &total=`30` &dateSource=`pub_date` &showInMenuOnly=`0` &showPublishedOnly=`1` &sortBy=`createdon` &depth=`3` &hideFolders=`1` &tpl=`rss_item`]]
    


    Would appreciate all help on this one, the site is almost re-built and will be going online in its new look and system shortly.

    Cheers in advance for any help smiley
      • 13226
      • 953 Posts
      Forgot to add: I am using Ditto 2.1+
        • 33337
        • 3,975 Posts
        Q1: Yes, thats possible. Just reference your TV as [+mytvname+]

        Q2: Yes, Ditto comes with PHx support by default, use PHx’s strip tags and character_limit functionality and you are good to go.
          Zaigham R - MODX Professional | Skype | Email | Twitter

          Digging the interwebs for #MODX gems and bringing it to you. modx.link
          • 13226
          • 953 Posts
          Cheers for the help "zi"

          Quote from: zi at Oct 20, 2009, 04:11 AM

          Q2: Yes, Ditto comes with PHx support by default, use PHx’s strip tags and character_limit functionality and you are good to go.

          Does that mean I have to install PHx ?

          How and where do I call the strip tag and character limit functions ?

          Cheers
            • 13226
            • 953 Posts
            Thanks to "zi" for putting me on the right track smiley

            I have now researched PHx and found its CustomModifiers.

            What I did

            As Ditto 2+ already supports PHx, there was no need to install the PHx plugin.

            To rectify the problem that I had I did the following:

            I created 2 snippets:

            phx:striptags
            <?php
            return($modx->stripTags($output, $options));
            ?>
            


            phx:word_limit
            <?php
            $retval = $output;
            $array = explode(" ", $output);
            
            if (count($array)<=$options)
            	 {
            	 $retval = $output;
            	 }
              else
            	 {
            	 array_splice($array,$options);
            	 $retval = implode(" ", $array);
            	 }
            
            return $retval;
            ?>
            


            The old call in the rss_item:
            <![CDATA[ <p>[+MYTVCONTENT+]</p> ]]>
            


            was changed to:

            The new call in the rss_item:
            <![CDATA[ <p>[+MYTVNAME:word_limit=`50`:striptags+]...</p> ]]>
            


            The new call delimits the snippets using ":" therefor both snippet calls are added in one.

            The end result is:
            <item>
              <title>[+rss_pagetitle+]</title>
              <link>[(site_url)][~[+id+]~]</link>
              <description>
                <![CDATA[ <p>[+MYTVNAME:word_limit=`50`:striptags+]...</p> ]]>
              </description>
              <pubDate>[+rss_date+]</pubDate>
              <guid isPermaLink="false">[(site_url)][~[+id+]~]</guid>
            </item>
            


            My Ditto Call:
            [[Ditto? &parents=`15` &format=`rss` &summarize=`30` &total=`30` &dateSource=`pub_date` &showInMenuOnly=`0` &showPublishedOnly=`1` &sortBy=`createdon` &depth=`3` &hideFolders=`1` &tpl=`rss_item`]]
            




            Cheers for the help smiley