We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11887
    • 34 Posts
    Is there a way of *grouping* items retrieved by FeedX, by a given field?

    For example, I'm using FeedX to retrieve calendar events from Google Calendar. The FeedX snippet call allows me to order the events, filter them, or template e.g. alternate events. The FeedX templating allows me to beautify the output.

    However I want to group the output into months.

    My output looks like:

    4 June, 9am: Sports Day
    9 June, All Day: Pastoral Day
    2 July, All Day: School trip

    I want my output to look like:

    JUNE EVENTS
    4 June, 9am: Sports Day
    9 June, All Day: Pastoral Day

    JULY EVENTS
    2 July, All Day: School trip


    I can't figure a way to do this with templating.
      • 43052
      • 1 Posts
      Ok, now I've been searching the life out of myself for a solution to this in the archives, so I hope you forgive me for posting this question. My very basic problem is that I don't understand ho to access the values of XML attributes from "inside" a template handling the presentation of it.

      I have a feed with XML from this (test) source: http://publish.ne.cision.com/Release/ListReleasesSortedByPublishDate/?pageSize=5&feedUniqueIdentifier=de922714f9 resulting in this output:

      <[b]Releases[/b] xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://publish.ne.cision.com/Schemas/releaselist.xsd" PageIndex="1" PageSize="5" TotalHits="24" SearchTime="0">
        <[b]Release[/b] Id="355323" InformationType="PRM" PublishDateUtc="2011-06-07T15:04:39" LastChangeDateUtc="2011-06-07T15:04:54" LanguageCode="sv" CountryCode="se" [b]DetailUrl[/b]="http://publish.ne.cision.com/Release/GetDetail/CCD08C8DD62DBB54" [b]CisionWireUrl[/b]="http://news.cision.com/se/test-it-leverans/r/test-rubrik,c9131635" LogoUrl="" SourceId="42255" [b]RawHtmlUrl[/b]="http://publish.ne.cision.com/Release/ViewReleaseHtml/CCD08C8DD62DBB54">
          <SyndicatedUrl><![CDATA[]]></SyndicatedUrl>
          <[b]SourceName[/b]><![CDATA[Test_IT_Leverans]]></SourceName>
          <SeOrganizationNumber></SeOrganizationNumber>
          <SourceIsListed>false</SourceIsListed>
          <IptcCode>00000000</IptcCode>
          <CustomerReference><![CDATA[]]></CustomerReference>
          <[b]Title[/b]><![CDATA[Test Rubrik]]></Title>
          <[b]Intro[/b]><![CDATA[Testutskick med bilder, videor, kategorier och taggar]]></Intro>
          <LanguageVersions CommonId="895055" />
      ...
        </Release>
      </Releases>
      


      My very basic problem is that I don't understand ho to access the values of XML attributes (like DetailUrl, CisionWireUrl and RawHtmlUrl) from within the template of Release.

      Inside of Release.tpl, I can access Title, Intro, SourceName and the other XML values (using [+TITLE+], etc), but what is the syntax for accessing the XML attributes? Can it be done?

      I *can* access the XML attributes from the template scope enclosing the Release.tpl, by using [+RELEASE.DETAILURL+], [+RELEASE.1.CISIONWIREURL+], etc.

      I was hoping to do this quite declaratively without coding.

      My Releases.tpl looks like this:
      <H2>(Releases.tpl)</h2>
      	<li> <b>ATTRIBUTES 1</b>
      	<li>RELEASE.INFORMATIONTYPE: [+RELEASE.INFORMATIONTYPE+]
      	<li>RELEASE.LASTCHANGEDATEUTC: [+RELEASE.LASTCHANGEDATEUTC+]
      	<li>RELEASE.TITLE: [+RELEASE.TITLE+]
      	<li>RELEASE.SOCIALMEDIAPITCH: [+RELEASE.SOCIALMEDIAPITCH+]
      	<li>RELEASE.DETAILURL: [+RELEASE.DETAILURL+]
      	<li>RELEASE.CISIONWIREURL: [+RELEASE.CISIONWIREURL+]
      	<li>RELEASE.RAWHTMLURL: [+RELEASE.RAWHTMLURL+]
      {{RELEASE->Release}}
      


      And Release.tpl looks like this:
      <li> (Release.tpl)RELEASE.PUBLISHDATEUTC: [+RELEASE.PUBLISHDATEUTC+]
      <ul>
      	<li> <b>VALUES</b>
      	<li> TITLE: [+TITLE+]
      
      	<li> <b>ATTRIBUTES 1</b>
      	<li>RELEASE.DETAILURL: [+RELEASE.DETAILURL+]
      	<li>RELEASE.CISIONWIREURL: [+RELEASE.CISIONWIREURL+]
      	<li>RELEASE.RAWHTMLURL: [+RELEASE.RAWHTMLURL+]
      </ul>
      


      And the result is something like this:

      (RELEASES.TPL)
      ATTRIBUTES 1
      RELEASE.INFORMATIONTYPE: PRM
      RELEASE.LASTCHANGEDATEUTC: 2011-06-07T15:04:54
      RELEASE.TITLE:
      RELEASE.SOCIALMEDIAPITCH:
      RELEASE.DETAILURL: http://publish.ne.cision.com/Release/GetDetail/CCD08C8DD62DBB54
      RELEASE.CISIONWIREURL: http://news.cision.com/se/test-it-leverans/r/test-rubrik,c9131635
      RELEASE.RAWHTMLURL: http://publish.ne.cision.com/Release/ViewReleaseHtml/CCD08C8DD62DBB54
      (Release.tpl)RELEASE.PUBLISHDATEUTC:
      VALUES
      TITLE: Test Rubrik
      LINK:
      ATTRIBUTES 1
      RELEASE.DETAILURL:
      RELEASE.CISIONWIREURL:
      RELEASE.RAWHTMLURL:
      


      And as you see, the values of for instance [+RELEASE.DETAILURL+] works fine in Releases.tpl, but is empty in Release.tpl.

      Is there a way to access it from Release.tpl? What is the syntax for that?

      Many thanks in advance for any hints.


        • 23491 ☆ A M B ☆
        • 1,056 Posts
        I was initially having a hard time figuring out sorting via FeedX. I had an RSS feed sorted chronologically, but only wanted the last 10 items, sorted by newest first.

        Here is an example from the snippet itself:
        Quote from: FeedX
        $params['sortElements'] = isset($sortElements) ? $sortElements : '';
            // Specify a field to perform a natural sort on, if %rand% is specified the elements will be randomized
            // ASC and DESC can be optionally be added to modify the order in which the elements are sorted
            // Syntax: ELEMENT_NAME(FIELDNAME)
            //         Multiple elements can be defined and must be separated by a colon
            // Example: `ITEM(PUB_DATE DESC)`

        This was exactly what I wanted, but as it turns out, the example provided was not a valid one, at least not in my case.

        The difference? PUBDATE vs. PUB_DATE

        Removing the underscore from the example is what finally got this to work for me. Adding the following to my FeedX snippet call took care of it:
         &sortElements=`ITEM(PUBDATE DESC)`


        As for limiting items, that was a bit trickier. I could not get maxElements=`10` to work. I was still able to use the "rss" preset, but it involved defining an `outerChunk` with subsequent calls to the CHANNEL + INNER TPLs. I had to create new chunks for each in order to finally pass the desired "limit" within the chunk itself:
        {{ITEM(10)->rss_item_tpl}}


        It wasn't until I got this working the long way that I figured out what I had initially done wrong:
        &maxElements=`10`

        Should have been:
        &maxElements=`ITEM(10)`


        Hopefully this saves somebody some time looking to do the same smiley
          Mike Reid - www.pixelchutes.com
          MODx Ambassador / Contributor
          [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
          ________________________________
          Where every pixel matters.