We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19534
    • 183 Posts
    Hey!

    For our blog we want to provide RSSs feed for our articles’ comments.
    For this purpose I created a resource with content type set to "RSS" which calls QuipRSS. This resource is requested via http://host/blog/comments-feed.rss?article=xy where ’article’ specifies the blog article of which the latest comments should be listed in the feed:

    [[!QuipRss?
    	&type=`thread`
    	&thread=`blog-post-[[!getReqParam? &name=`article`]]`
    	&containerTpl=`rssFeed.article`
    	&pagetitle=`[[!getResourceField? &id=`[[!getReqParam? &name=`article`]]` &field=`pagetitle`]]`
    ]]
    


    Note: Because the article’s pagetitle is only set by QuipRSS when there are already comments available, I added the &pagetitle parameter (see https://github.com/splittingred/Quip/pull/43).

    This works fine but the http://host/blog/comments-feed.rss?article=xy are not really nice and friendly (for SEO, too).

    I thought of URLs like this: http://host/blog/article1.html/comments.rss, http://host/blog/article2.html/comments.rss, ... http://host/blog/articleXY.html/comments.rss and created a plugin (QuipRSSFurl) which does this job:

    The original comments-feed.rss resource (http://host/blog/comments-feed.rss) is still used to create the RSS files. Additionally the new QuipRSSFurl plugin listens to OnPageNotFound events, checks whether the requested URL ends with the /comments.rss suffix (it offeres multi language support for the suffix), sets the ’article’ GET param and forwards the request to the comments-feed.rss resource:

    /**
     * QuipRSSFurl
     *
     * Author Jakob Class <[email protected]>
     *
     * Plugin which fetches 404 errors to provide RSS Feeds when a blog article is 
     * requested with a special suffix (/[quip.comments].rss).
     * 
     * @package quip
     */
    if ($modx->event->name != 'OnPageNotFound') return;
    
    
    $rssResourceId = $modx->getOption('quip.comments_rss_resource_id','',null,'');
    if (empty($rssResourceId)) return;
    
    /* check if requested resource ends with correct suffix */
    $modx->getService('lexicon','modLexicon');
    $modx->lexicon->load('quip:default');
    $suffix = '/'.strtolower($modx->lexicon('quip.comments').'.rss');
    $search = $_SERVER['REQUEST_URI'];
    $base_url = $modx->getOption('base_url');
    if ($base_url != '/') {
        $search = str_replace($base_url,'',$search);
    }
    $search = strtolower(trim($search, '/'));
    if(substr( $search, -strlen($suffix) ) != $suffix) return;
    
    /* check for orginal resource (without suffix) */
    $search = str_replace($suffix,'',$search);
    $resourceId = $modx->aliasMap[$search];
    if (empty($resourceId)) return;
    
    /* set parameters for QuipRSS resource */
    $_GET['article'] = $resourceId;
    
    /* forward */
    $modx->sendForward($rssResourceId);
    return;
    


    To make this plugin work you have to specify the id of the comments-feed.rss resource (http://host/blog/comments-feed.rss) via the system setting ’quip.comments_rss_resource_id’.

    @Shaun: If you like me to pull this code to your GitHub repository, just tell me!

    Cheers,
    Jakob
      Add-On to easily manage your multilingual sites: Babel
      • 22446
      • 181 Posts
      jakob,

      The plugin you have built sounds like something I am interested in.

      I would like to clarify what you are doing.

      1) Creating a blank resource with content type set to RSS
      2) In this resource you are calling out the QuipRss snippet (Can you explain what you are doing in &thread, and &pagetitle?)
      [[!QuipRss?
      	&type=`thread`
      	&thread=`blog-post-[[!getReqParam? &name=`article`]]`
      	&containerTpl=`rssFeed.article`
      	&pagetitle=`[[!getResourceField? &id=`[[!getReqParam? &name=`article`]]` &field=`pagetitle`]]`
      ]]


      3) Installing the plugin that you wrote and setting the ID of the comments-feeds.rss resource in the system settings under ’quip.comments_rss_resource_id’

      I don’t understand the use of article. I don’t have a blog. How can I modify what you have to display RSS feeds based on comments left on other resource pages?
        • 19534
        • 183 Posts
        article is just a HTTP-GET variable containing the ID of the resource whose latest comments should be displayed.
          Add-On to easily manage your multilingual sites: Babel