Jul 05, 2009, 09:34 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Donate to MODx: Donations
Pages: [1] 2   Go Down
  Print  
Author Topic: [Snippet] NewsParserX (version 0.9)  (Read 14380 times)
0 Members and 1 Guest are viewing this topic.
OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,814


damn accurate caricatures...


WWW
« on: Jan 15, 2006, 01:32 PM »

Here's an old NewsParser snippet variation I created back at Etomite that does work with multiple instances per page.

Extract this into the directory /assets/snippets/newsparserx/ and then copy and paste the newslisting.snippet.txt contents into a new snippet that you can call from your pages.

Sample Call
Code:
$snippetOutput .= $modx->runSnippet('NewsParserX',array('url'=>'http://domain.tld/feed_url'));

[UPDATE: version 0.9 posted 2006-04-02 to address html entities in complex feed URLs, e.g. those will query string parameters]

* newsparserx.0.9.zip (5.75 KB - downloaded 579 times.)
« Last Edit: Apr 02, 2006, 01:03 PM by OpenGeek » Logged

Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa
davidm
MODx evangelist
Marketing & Design Team
*
Posts: 7,026


Software is like sex, it's better when it's free !


WWW
« Reply #1 on: Jan 15, 2006, 04:53 PM »

Waow Jason, just when we were discussing this !

That was fast !!!
Thanks Smiley
Logged

.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez ŕ l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accčs pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net
sottwell
Documentation Team
*
Posts: 8,837



WWW
« Reply #2 on: Jan 31, 2006, 09:23 AM »

I've never worked with newsfeeds before.  How would I get the rss feed from here?

Code:
http://modxcms.com/forums/index.php?sa=recent;type=rss2;action=.xml&limit=20

Is this the url I use? Do I need to make another snippet to call the NewsParserX snippet, or can I call the NewsParserX snippet directly in my template?

Logged

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
sottwell
Documentation Team
*
Posts: 8,837



WWW
« Reply #3 on: Jan 31, 2006, 09:48 AM »

To answer my own questions: Yes, and yes.

I created a second snippet named ParseNews, with just this code:

Code:
return $modx->runSnippet('NewsParserX',array('url'=>'http://modxcms.com/forums/index.php?sa=recent;type=rss2;action=.xml&limit=6'));

Called ParseNews in my template.

And the results:
http://www.sottwell.com
Logged

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
sottwell
Documentation Team
*
Posts: 8,837



WWW
« Reply #4 on: Jan 31, 2006, 10:15 AM »

I have a question.  The links open in the same browser window, taking the user out of my site.  How would I go about having the links open in a new window?

I hacked the newsparserx.inc.php file adding

Code:
target="_blank"

to all the links. Is there a better way?
« Last Edit: Jan 31, 2006, 10:25 AM by sottwell » Logged

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
davidm
MODx evangelist
Marketing & Design Team
*
Posts: 7,026


Software is like sex, it's better when it's free !


WWW
« Reply #5 on: Jan 31, 2006, 10:38 AM »

Thanks Susan for sharing all this, pretty useful !

And, by the way, nice port of YAML theme : nice clean looking template Smiley
Logged

.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez ŕ l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accčs pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net
sottwell
Documentation Team
*
Posts: 8,837



WWW
« Reply #6 on: Jan 31, 2006, 10:49 AM »

The template is clean enough, but the CSS is a major ... something. The main css file calls three or four others, plus he provides css files for a couple of different layouts using the same template. I've been very careful to leave the basic html alone, and to leave the css completely alone.  I just add what I need for the various forms and stuff I've added.
Logged

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,814


damn accurate caricatures...


WWW
« Reply #7 on: Jan 31, 2006, 11:46 AM »

The best way to modify for opening links in a new browser window, if you are interested in keeping it XHTML/CSS compliant, is to use the rel attribute to describe links to be opened in a new window in a standard way.  A common approach is using rel="external" to describe links like this, and then use a script like this to do the work:
Code:
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;

Make sure the script is loaded in the HEAD of your document (either from an external file registered as a startup script or putting the script in the HEAD of your template), and in browsers that support JS and the DOM methods above, you'll get appropriate navigation, and will be ready to support browsers that might not be able to follow the old target="_blank" links (think mobile devices and other specialized browser platforms) with full compliancy.
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa
rthrash
Foundation
*
Posts: 10,471



WWW
« Reply #8 on: Jan 31, 2006, 12:33 PM »

Jason, I think you need to make a plugin out of that... would be killer!
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
sottwell
Documentation Team
*
Posts: 8,837



WWW
« Reply #9 on: Feb 20, 2006, 08:32 AM »

If it can't connect to the given URL it puts up a nasty MODx error page.  I haven't been able to get it to simply return false on failure to connect.
Logged

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
gigli
Jr. Member
*
Posts: 28


WWW
« Reply #10 on: Feb 23, 2006, 03:17 PM »

Thank you very much for this useful snippet!!
Logged
Trance
Jr. Member
*
Posts: 46


I love MODx!


WWW
« Reply #11 on: Mar 22, 2006, 01:05 PM »

I got a bit of trouble to read out a RSS feed from my IPB forums.  This is the URL

http://gamerscollective.com/forums/index.php?act=rssout&id=3

Code:
return $modx->runSnippet('NewsParserX',array('url'=>'http://gamerscollective.com/forums/index.php?act=rssout&id=3'));

This is what I get when I call the snippet: http://stage.server02.com/modx/index.php?id=39 (please look at the link)

It is a valid RSS feed, since my RSS reader picks it up no problem. Only  am concerned about the "?act=" part in the URL.  Any thoughts on how to kill this bird ??

Logged

OpenGeek
MODx Co-Founder
Foundation
*
Posts: 5,814


damn accurate caricatures...


WWW
« Reply #12 on: Mar 22, 2006, 02:10 PM »

I got a bit of trouble to read out a RSS feed from my IPB forums.  ...
It is a valid RSS feed, since my RSS reader picks it up no problem. Only  am concerned about the "?act=" part in the URL.  Any thoughts on how to kill this bird ??

Hmmm, same result when I try to load it as well.  I'll have to look into the problem, but I'm a little swamped today.  If you don't hear from me in a couple of days, feel free bump this thread to remind me.  Of course if you figure out the issue in the meantime, I'm sure you'll share that as well...
 Wink
Logged

Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa
Duane
Member
**
Posts: 51


« Reply #13 on: Mar 28, 2006, 03:30 PM »

I'm well on my way to proving my complete stupidity...but, I'm getting nowhere being stubborn and trying to figure this out on my own.

I can't seem to wrap my brain around this whole process. I followed the instructions in the original message, and got...nothing.

I then followed Susan Ottwell's followup procedure, and at least got "no entries found" to display.  Undecided

That's where I've been for 2 hours now.

So, here's what I've done:

1.  I put the contents of the zip file into /assets/snippets/newsparserx

2. I created a new snippet called NewsParserX and pasted the newslisting.snippet.txt into it.

Then, I put [[NewsParserX]] into the template.

Nothing.

So, I followed the slightly different procedure spelled out by Susan Ottwell, and created a snippet called "parseNews" with the return $modx->runSnippet line as it's only content, and put [[parseNews]] into my template. That gets me the "no entries found" output.

I can't seem to figure out, step by step, what I should be doing. And, the original instructions from Jason seem substantially different from what Susan did. What goes where? And, what should I put in the template?

Thanks. Sorry to be dumb.

Duane

Logged
garryn
Coding Team
*
Posts: 1,252



WWW
« Reply #14 on: Mar 28, 2006, 03:40 PM »

Hi Duane,

Are you passing a URL in the snippet call? If [[NewsParserX]] returns 'No Entries Found' then, for all intents and purposes, I think the snippet is working. You just need to tell it where to get the feed  Wink

So, something like this should work:
Code: (Snippet Call)
[[NewsParserX? &url=`http://domain.tld/feed_url`]]
Logged

Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!