We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17301
    • 932 Posts
    Hello,

    Is it possible to have a getResources/getPage call pulling in a a bunch of resources (collections) sorted by published date AND then to also additionally pull in an RSS feed (using parseX), that is also in order with the set of collections?

    Hopefully that makes sense.

    Thanks,
    [ed. note: lkfranklin last edited this post 10 years, 1 month ago.]
      ■ email: [email protected] | ■ website: https://alienbuild.uk

      The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
      • 17301
      • 932 Posts
      Additionally, is it also possible to do it with TwitterX also?
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 10208 ☆ A M B ☆
        • 1,780 Posts
        https://forums.modx.com/index.php?action=thread&thread=55703&i=1

        This might help you. With getResources, you can only "get MODX resources" so you'll need to create a weblink resource set to the url of the RSS feed and make sure to place it into the parent resource in the order in which you want it to be displayed if you're using &sortBy=`menuindex`.

        From what I recall, twitterX will not work with getResources however it might be possible to insert a twitterX call into your tpl for the Twitter account you set up for twitterX. However, if you need results from different Twitter accounts I do not believe it's possible to set up more than one.
          Frogabog- MODX Websites in Portland Oregon
          "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
          Having server issues? These guys have MODX Hosting perfected - SkyToaster
          • 17301
          • 932 Posts
          Thank you for your reply Frogabog.

          I see what you're saying re the getResources only getting MODX resources. I have ParseX setup in its own resource to get a bunch of different feeds and they output fine on its own page and I can also output them along side my getResources but of course they wont be in published order. However, both the getResources call and the parseX do have a published on and pubDate and both of these entities do exists before the page is rendered. Surely there must be a way of turning the 'pubDate' from the parseX feed into a database entry that can be inserted into the getResources 'publishedon' and then sorted by the &sorby=`` option.

          Though I'm just speculating and have no idea how to go about doing that... :/


            ■ email: [email protected] | ■ website: https://alienbuild.uk

            The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
            • 26681 MODX Staff
            • 123 Posts
            You would need a custom Snippet for this, although it should be fairly straightforward. Essentially (it sounds like) you want an array of items which is merged from an array of MODX Resources and another array of items fetched from RSS. You would want this merged array to be keyed off the publish date. Then you would sort the array and iterate through it, applying your MODX tpl Chunk to each item.

            Here's some pseudo code:

            // Target outputArray
            $outputArray = array();
            
            // MODX Resource query
            $query = $modx->newQuery('modResource');
            
            // add your $query criteria using methods like $query->where(), then:
            
            $resources = $modx->getCollection('modResource', $query);
            // Iterate
            foreach ($resources as $res) {
                // key the outputArray elements off the raw publishedon date value
                $outputArray[$res->publishedon] = $res->toArray(); 
                // Fetch TVs if you need them and add them to the array element $outputArray[$res->publishedon]
            }
            
            // Now get RSS feed into another array
            $rssItems = $feedGettingClassInstance->getFeed('from_somewhere');
            
            foreach ($rssItem as $item) {
                // key the outputArray elements off the pubDate value
                $outputArray[$item->pubDate] = $item->someMethodToMakeArrayWithSameKeysAsResources();
            }
            
            sort($outputArray);
            
            $output = '';
            foreach($outputArray as $element) {
                // process with chunk named $tpl and add to output
                $output .= $modx->getChunk($tpl, $element);
            }
            return $output;
            


            Does that help at all?
              [sepiariver.com] (https://sepiariver.com/)
              • 17301
              • 932 Posts
              Thank you.

              I decided it was too much for me though and have paid another developer to do this for me.

              Thanks for your help though.
                ■ email: [email protected] | ■ website: https://alienbuild.uk

                The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.