We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4971
    • 964 Posts
    Neat... that is how it is done!!

    @jesse
    how does it work? I mean... how do you know that day(1,2) will choose the second day?
    or part(3,1) will choose the third forecast? This two seem backwards don´t they?
      Website: www.mercologia.com
      MODX Revo Tutorials:  www.modxperience.com

      MODX Professional Partner
      • 14050
      • 788 Posts
      Quote from: ApoXX at Mar 04, 2007, 12:38 PM

      Also, the order of the (optional) offset and limit for chunk calls has been switched. Should be: {{ITEM(limit,offset)->chunkName}} rather than {{ITEM(offset,limit)->chunkName}}

      Here is the syntax. And yes, the Part(3,1) does appear to be backwards. I think it might be a bug and maybe the order of the optional offset and limit didn’t get changed for all elements. But if you change it to PART(1,3), it doesn’t render any output. Maybe Brian can answer this for us. Brian, if you need I can zip up the template package for this and give you access to my Weather.com feed.
        Jesse R.
        Consider trying something new and extraordinary.
        Illinois Wine

        Have you considered donating to MODx lately?
        Donate now. Every contribution helps.
        • 7923
        • 4,213 Posts
        Could this snippet be added to the resource repository?


          "He can have a lollipop any time he wants to. That's what it means to be a programmer."
          • 6470
          • 69 Posts
          Quote from: ApoXX at Mar 02, 2007, 11:31 AM

          Thanks for testing. You’re right, PHx is interpreting the colon as a modifier. The best solution at this point would be to simply replace colons with another character; how about a dash/minus or perhaps the pipe symbol?

          I’d be glad to add a function for returning the cached/parsed data structure. You should also be able to access it like:
          Edit...

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

          The cacheType must be set to 0 for this to work correctly; let me know what method for retrieving the data works best for you.

          Also, what do you think about the current method of passing a configuration array to the class, would it be any easier for you if I also wrote a function for setting the configuration parameters?

          I need some help to figure out How to pass parametrs into FeedX instance
          I tryed with no result
          I made rss snippet and put it in a page [!rss!]
          
          <?php
          $config="url=`http://feeds.feedburner.com/ListenToEnglish-LearnEnglish?format=xml`&cacheType=`0`&maxElements=`ITEM(3)`";
          $feedx = new FeedX($config);
          $feedx->getData();
          $myData = $feedx->items[3];
          
          print_r($myData);
          ?>
          

          it returns
          Fatal error: Class ’FeedX’ not found in z:\home\modx\www\manager\includes\document.parser.class.inc.php(766) : eval()’d code on line 3

          but when I use it with a Feedx snippet it works fine
          [!FeedX? &url=`http://feeds.feedburner.com/ListenToEnglish-LearnEnglish|xq|format|xe|xml`&debug=`1`&cacheType=`0`&preset=`podcast`&maxElements=`ITEM(3)`!]

          Also I tryed to insert just url content, ..

          Need Help
            • 6470
            • 69 Posts
            Would anyone tell me the solution!!!
            Is anybody here...

            Those message I receive when trying to get rss feed via the following call
            <?php
            $url="http://feeds.feedburner.com/ListenToEnglish-LearnEnglish?format=xml";
            $feedx = new FeedX($url);
            
            
            $feedx->getData();
            $myData = $feedx->rss;
            
            print_r($myData);
            ?>


            « MODx Parse Error »MODx encountered the following error while attempting to parse the requested resource:
            « PHP Parse Error »

            PHP error debug
            Error: file_get_contents(h) [function.file-get-contents]: failed to open stream: No such file or directory
            Error type/ Nr.: Warning - 2
            File: z:\home\modx\www\assets\snippets\FeedX\classes\feedx.class.inc.php
            Line: 294
            Line 294 source: $xml = file_get_contents($this->config[’url’]);

            Parser timing
            MySQL: 0.0098 s (3 Requests)
            PHP: 0.1702 s
            Total: 0.1801 s

            How to get it working
              • 14050
              • 788 Posts
              What exactly are you trying to accomplish where you need to call an instance of FeedX within your snippet?
                Jesse R.
                Consider trying something new and extraordinary.
                Illinois Wine

                Have you considered donating to MODx lately?
                Donate now. Every contribution helps.
                • 6470
                • 69 Posts
                Quote from: jesster444 at Jun 12, 2007, 04:41 PM

                What exactly are you trying to accomplish where you need to call an instance of FeedX within your snippet?

                Well I need to parse remote rss feed and publish{insert} it in a modx page
                and so forth to publish any coming rss updates to modx page

                that is why i am writing my own snippet, also i need to do some fields proccesing and char replace.

                I managed to get some data out of the following call
                but in very inconvinient way,
                have a look
                $feedx->config['url'] = 'feeds.feedburner.com/ListenToEnglish-LearnEnglish?format=xml'; 
                $filename="assets/snippets/FeedX/classes/feedx.class.inc.php";
                include($filename);
                $filename1="assets/snippets/FeedX/classes/debug.class.inc.php";
                include($filename1);
                
                $config[url]='http://feeds.feedburner.com/ListenToEnglish-LearnEnglish?format=xml';
                $config[cacheType] ='0';
                $config[debug] ='1';
                $config[cacheTime] ='9000';
                $config[cachePath] ='assets/snippets/FeedX/';
                
                
                $feedx = new FeedX($config);
                
                
                $feedx->getData();
                
                $myData1 = $feedx->elements[0][children][0][children][33][children][0][value]; //date published
                $myData2 = $feedx->elements[0][children][0][children][33][children][1][value]; //title
                $myData3 = $feedx->elements[0][children][0][children][33][children][10][value]; //ITUNES:SUBTITLE
                $myData4 = $feedx->elements[0][children][0][children][33][children][12][value]; //DESCRIPTION

                Is it possible to directly call ITEMS1,2,3.4 [description][title] etc, without digging inside the feedx; output,
                doing it manually,?
                I mean every feed version is different, so numbers may change
                  • 14050
                  • 788 Posts
                  I think you can accomplish what you are trying to do using Templates and PHx, both supported in FeedX.

                  If you are trying to parse an rss feed, take a look at the files located at:

                  assets/snippets/FeedX/tpl/rss/

                  To manually get at the items, look at channel.tpl and change:

                  {{ITEM->item}}


                  to

                  {{ITEM(4,0)->item}}


                  The syntax of that is {{ITEM(limit,offset)->tplName}}

                  If you needed to do something different with each item, you could them do something like:

                  {{ITEM(1,0)->item1}}
                  
                  {{ITEM(1,1)->item2}}
                  
                  {{ITEM(1,2)->item3}}
                  
                  etc. 


                  and make sure you have template files for item1, item2, item3, etc.

                  To do some field processing and character replacements, PHx comes in handy. For an example of how that works with PHx. This is the example found in assets/snippets/FeedX/tpl/google_calendar/_readme.txt:


                  Preset for Google Calendar
                  --------------------------
                  
                  For date parsing via PHx, create a new snippet named: phx:google
                  And enter the following PHP code:
                  
                  <?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;
                  }
                  ?>
                  
                  Then change:
                  
                  <p><b>Starts:</b> [+GD|WHEN.STARTTIME+] <br />
                  <b>Ends:</b> [+GD|WHEN.ENDTIME+]</p>
                  
                  To:
                  
                  <p><b>Starts:</b> [+GD|WHEN.STARTTIME:google=`%B %d, %G @ %T`+] <br />
                  <b>Ends:</b> [+GD|WHEN.ENDTIME:google=`%B %d, %G @ %T`+]</p>


                  More examples of PHx usage can be found throughout this thread, by searching the forum, and by looking at the Wiki located here:

                  http://wiki.modxcms.com/index.php/PHx
                    Jesse R.
                    Consider trying something new and extraordinary.
                    Illinois Wine

                    Have you considered donating to MODx lately?
                    Donate now. Every contribution helps.
                    • 6470
                    • 69 Posts
                    <!--"..not to do it Manually .." I meant do not use Feedx output for searching all related elements and their numbers and childrens-->

                    Actually I need to know how to get data from FeedX instance easily and directly

                    something like

                    $item1[description] = $feedx->elements[Item1][description];

                    instead of
                    $myData1 = $feedx->elements[0][children][0][children][33][children][0][value]; //description


                    what is working perfect but I mad about digging inside feedx output to get all of these children and their location

                    I don’t whant to use snippet call on page [!Feed ....!] As for I do some postproccing with [preg_replace] directly what is easia for me
                    Also I have built working templates for the above call, but I don’t know how to use them with direct Feedx instance call
                    I mean I just dont get it how to pass templates to

                    $feedx = new FeedX($config); instance
                    and how to fill\get them then

                    and if I have alreasy build template preset what is it for if i can get data from feedx instance.

                    Need probably some futher explanation

                    Once again thanx for replay  jesster444

                    This thread so quiet....

                    Daniel
                    --------------------------------------------

                    There must be a solution for that..?

                    How to call my [!FeedX? &url=`http://feeds.feedburner.com/ListenToEnglish-LearnEnglish|xq|format|xe|xml`&debug=`1`&cacheType=`0`&preset=`podcast`&maxElements=`ITEM(4)`!] snippet.
                    and get data stored in array
                    Item1[description],,item1[title]
                    item2[description]
                    and so on.
                    I think it is very easy, but how?????????????????????
                    I need fields for futher proccesing one, by one,
                      • 6470
                      • 69 Posts
                      FeedX do not parse

                      http://www.comedycentral.com/rss/jokes/index.jhtml

                      what might be the problem

                      simplepie reader do it