We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 14050
    • 788 Posts
    Yeah, seriously. Where were you sooner? This would have made authoring my WeatherX and GoogleEvents snippets a lot easier :-D
      Jesse R.
      Consider trying something new and extraordinary.
      Illinois Wine

      Have you considered donating to MODx lately?
      Donate now. Every contribution helps.
      • 15987
      • 786 Posts
      Apoxx,
      Looks great, I will give it a run this weekend and report back.

      Thanks for the great code.

      Kyle
        • 14050
        • 788 Posts
        Demo here of some date beautification with phx, prebeautification can be seen for the "Ends:" date:

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

        The code is for phx:google:
        <?php
        if (strpos($output, 'T')) {
        
        	$mystring = str_replace('T', ' ', $output);
        	$mystring = substr($mystring, 0,16);
        	$dt = strftime($options,strtotime($mystring));
                if ($modx->config['modx_charset'] == 'UTF-8')
        	    $dt = utf8_encode($dt);
        	return $dt;
        }
        else {
        	$dt = strftime($options,strtotime($output));
                $dt = trim(substr($dt,0,strpos($dt, '@')));
               return $dt;
        }
        ?>


        And the entry.tpl file looks like:

        <h2><a href="[+LINK.1.HREF+]">[+TITLE+]</a></h2>
        <p><b>Starts:</b> [+GD|WHEN.STARTTIME:google=`%B %d, %G @ %T`+] <br />
        <b>Ends:</b> [+GD|WHEN.ENDTIME+]</p>
        <p><b>Where:</b> [+GD|WHERE.VALUESTRING+]<br /></p>
        <p><b>Description:</b> [+CONTENT+]</p>


        Of course this is purely for the Google Calendar and my entry.tpl, but should serve as a good example nonetheless. Want me to post some explanation and post this in the Wiki? It allows someone to make short work of most XML feeds, even one as complicated as the Google Calendar feed.

          Jesse R.
          Consider trying something new and extraordinary.
          Illinois Wine

          Have you considered donating to MODx lately?
          Donate now. Every contribution helps.
          • 1932
          • 137 Posts
          Looks really nice jesster. laugh

          Yeah, feel free to add a Wiki entry; I’ll prepare a main entry for FeedX when I make an official release for it and link up any related wiki posts.



          I also wanted to mention that the chunk calling placeholders can be used multiple times. This could be useful for separating items into columns or emphasizing certain elements using the offset and limit syntax. The below example would put the first item in a div and the following 10 items in an unordered list:

          <div class="main">{{ITEM(0,1)->mainItem}}</div>
          <ul>
                  {{ITEM(1,10)->subItem}}
          </ul>
          




          EDIT: A new preset for displaying Flickr photos has been added to the Zip download (in the first post of this thread). The correct format needs to be specified, please look at the _readme.txt within the preset directory for an example URL.
            • 15987
            • 786 Posts
            jesster,
            looks like the google events snippet is now obsolete, nice work.
              • 14050
              • 788 Posts
              @Kyle We would still need to access the Elements array to sort the items, no? Right now I can only sort it in reverse chronological, as Google only allows the parameter "oderby=starttime" or "orderby="lastmodified." Also, I think I know how to implement the event calendar with FeedX, but am not 100% sure. And if we do migrate to FeedX, it would be nice if anyone knew of an unobtrusive javascript event calendar for some ajax goodness. It might still be worthwhile to implement GoogleEvents using FeedX, just so the users of it don’t have to learn a new snippet, yet they can still get the performance gains from it. Sadly, I am unsure how how to tackle this inside GoogleEvents, and was hoping you were still planning on doing this so I could learn from it. grin

              @Brian, would it be possible to add the following parameters:


              • $maxItems - Limit the amount of items returned to this number.
              • $skipItems - Skip this many items and start displaying the one after this number.
              • $tplPresetFirst - The TPL for the first item
              • $tplPresetLast - The TPL for the last item
              • $tplPresetOdd - The TPL for an Odd item
              • $tplPresetEven - The TPL for an Even item

              I understand that I can template using ITEM array, but these templates parametes would be nice.

              Also, if you want to add my templates as an option in your package for GoogleCalendar, feel free.
                Jesse R.
                Consider trying something new and extraordinary.
                Illinois Wine

                Have you considered donating to MODx lately?
                Donate now. Every contribution helps.
                • 17717
                • 433 Posts
                Would it be possible to post an installation guide, desperately trying to get a few flickr images on my MODx site. I have uploaded the FeedX folder to my snippets folder. Do I need to create a snippet in the backend?

                Thanks
                Lee
                  http://www.blend.uk.com | Web Design by Blend
                  • 14050
                  • 788 Posts
                  You need to make a snippet call like:

                  [!FeedX? &url=`http://api.flickr.com/services/feeds/photos_public.gne` &tplPreset=`flickr`!]


                  Of course you would need to change the URL to the one you want. You can find more about the feeds here:

                  http://www.flickr.com/services/feeds/docs/photos_public/

                  If you have a ’?’, ’=’, or an ’&’ in the actual feed address, then you need to change those to |xq|, |xe|, or |xa|, respectively, in your snippet call.

                  For example. If the address to your feed was:

                  http://api.flickr.com/services/feeds/photos_public.gne?id=31701561@N00

                  Then your call would be:

                  [!FeedX? &url=`http://api.flickr.com/services/feeds/photos_public.gne|xq|id|xe|31701561@N00` &tplPreset=`flickr`!]
                    Jesse R.
                    Consider trying something new and extraordinary.
                    Illinois Wine

                    Have you considered donating to MODx lately?
                    Donate now. Every contribution helps.
                    • 17717
                    • 433 Posts
                    just added the full url (added |xa|format|xe|rss2 to the above) and hey presto it worked, thanks for your help man... really appreciate it.

                    Thanks
                    Lee
                      http://www.blend.uk.com | Web Design by Blend
                      • 14050
                      • 788 Posts
                      Any idea why this call:

                      [!FeedX? &url=`http://api.flickr.com/services/feeds/photos_public.gne|xq|format|xe|rss2` &tplBuilder=`1`!]


                      Generates the the following tplBuilder code:

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

                      Instead of the RSS2 elements that you would see at this feed:

                      http://api.flickr.com/services/feeds/photos_public.gne?format=rss2
                        Jesse R.
                        Consider trying something new and extraordinary.
                        Illinois Wine

                        Have you considered donating to MODx lately?
                        Donate now. Every contribution helps.