Subscribe: RSS
  • you have to replace the ? with |xq| and replace the = with |xe| and any & with |xa| in your snippet call
    • Quote from: kylej at Mar 02, 2007, 06:22 PM


      $feedx = new FeedX($config);
      $feedx->execute();
      $mydata = $feedx->elements;

      this would be fine, however... if it could return the cached data if it exists that would be great also. I have no problem with setting up a parameter array, so you don’t need to change that.


      Make it a parameter and it defaults to a pipe symbol would be my suggestion.

      sounds like a good idea to me

      It will automatically return the cached data if available and up to date, otherwise it will re-retrieve the data and populate the data array.

      I’ll go ahead and add a new configuration parameter for replacing the colon.

      @jester444:

      Thanks for bringing this up, I’ll try to come up with a solution today. Mind sharing the original xml URL?
      • Here it is...it is a test Google Calendar feed:

        http://www.google.com/calendar/feeds/iblewyouup@gmail.com/public/full
          Jesse R.
          Consider trying something new and extraordinary.
          Illinois Wine

          Have you considered donating to MODx lately?
          Donate now. Every contribution helps.
        • Quote from: kylej at Mar 02, 2007, 07:06 PM

          you have to replace the ? with |xq| and replace the = with |xe| and any & with |xa| in your snippet call

          Ah, that worked! Thanks. Bw, is there a way to get that automated?

          Another problem...

          I want to build own templates as chunks from the modx-backend. I just copy’n’pased the rss .tpl files as single chuncks into the backend with the same names and tried to call it with &outerChunk=’outer’ . But this doesn’t work. I just get a plain screen. Any help upon that?
          • Quote from: 020200 at Mar 02, 2007, 07:40 PM

            Ah, that worked! Thanks. Bw, is there a way to get that automated?

            Another problem...

            I want to build own templates as chunks from the modx-backend. I just copy’n’pased the rss .tpl files as single chuncks into the backend with the same names and tried to call it with &outerChunk=’outer’ . But this doesn’t work. I just get a plain screen. Any help upon that?

            There currently isn’t a way to automate the process of converting characters in the URL since the characters conflict with the snippet parser. It is possible to write a little web utility that would automatically convert the URL before you manually enter it into the snippet.

            UPDATE: There was a slight problem in the snippet code when using chunks, I’ve updated it above. The downloaded files should not need changing.
            • I’ve updated the code/zip file in the first post of the thread to include colon replacement as well as adding an incremental integer when encountering duplicate items (within the same xml depth):

              [+LINK.HREF+]
              [+LINK.TITLE+]
              [+LINK.1.TYPE+]
              [+LINK.1.HREF+]

              etc.

              Let me know how it works. wink

              @kylej:

              To avoid unnecessary rendering when you are retrieving the data structure, I have created a separate function to only get the parsed xml data (it will also re-retrieve if the cache has expired). Please follow the below example:

              $feedx = new FeedX($config);
              $feedx->getData();
              $yourarray = $feedx->elements;  // or reference $feedx->elements directly
              


              If you need to change the URL or other configuration parameters used by FeedX, you can do it within a single instance rather than having to create separate instances every time:

              $feedx->config['url'] = 'new url';  // Be sure to use ? & and = in this URL rather than replacing
              $feedx->getData();  // Get new feed
              




              By the way, my current template presets are pretty weak at the moment - if anyone wants to share their own creations I’d be glad to bundle them as the defaults.
              • Quote from: ApoXX at Mar 02, 2007, 08:13 PM

                UPDATE: There was a slight problem in the snippet code when using chunks, I’ve updated it above. The downloaded files should not need changing.

                Works! smiley
                • Seems to be working. I have a demo running here:

                  http://www.cmssandbox.com/MODx095/index.php?id=57

                  @Brian: To parse the start and end times into presentable formats, would I use PHx or would I have to access the array of elements like you described earlier?

                  @Kyle: I am not working on integrating this into GoogleEvents, so don’t worry about us working on the same thing. I am just trying to wrap my head around the potential of this snippet.
                    Jesse R.
                    Consider trying something new and extraordinary.
                    Illinois Wine

                    Have you considered donating to MODx lately?
                    Donate now. Every contribution helps.
                  • You could probably use PHx, but you would have to use a custom (user-installed) modifier. Here is a little example which should be able to read in nearly any date and format it using PHP’s strftime() syntax:

                    Snippet Name: phx:str2date
                    <?php
                    if (($time = strtotime($output)) !== false)
                    {
                    	$dt = strftime($options, ($time + $modx->config["server_offset_time"]));
                    	if ($modx->config['modx_charset'] == 'UTF-8')
                    	    $dt = utf8_encode($dt);
                    	return $dt;
                    }
                    else
                    	return $output;
                    ?>
                    


                    Then inside your template/chunk:

                    <li><a href="[+LINK+]" title="Posted on [+PUBDATE:anydate=`%A`+]">[+TITLE+]</a></li>


                    I should also note that cacheType should be set to `0` during testing or your template changes won’t show up until the cache expires. Also, any PHx modifiers that change dynamically (based on time of day, logged in user, etc) won’t change until the cache expires if cacheType is set to `1`.
                    • Core integration here we come smiley This is almost too powerful! Awesome!
                        Mike Reid - www.pixelchutes.com
                        MODx Ambassador / Contributor
                        [Module] MultiMedia Manager / [Module] SiteSearch / [Snippet] DocPassword / [Plugin] EditArea / We support FoxyCart
                        ________________________________
                        Where every pixel matters.