![]() |
|
Made my own RSS Feed - useful? - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: Made my own RSS Feed - useful? (/thread-739.html) Pages:
1
2
|
Made my own RSS Feed - useful? - WillHamilton - 15-08-2006 To be honest I don't really understand RSS - I just use it with Live Bookmarks in Firefox, not with an outside feed reader. That said, I made this simple feed for the part of my site that uses zenphoto: http://www.bridgetothestars.net/fanart/rss.php As far as I'm aware the only thing it doesn't include is the publication date, which I don't see in Live Bookmarks anyway, so it doesn't concern me! If it's not absolute rubbish and might be of use to someone then ask here and I'll explain how I went about making it. Made my own RSS Feed - useful? - trisweb - 15-08-2006 Should just be another theme page, am I right? With a different output XML, but still just grabbing and looping stuff like a normal theme? We've got the workings of RSS in SVN, but it was really buggy for the separate feeds and such we were trying to do, so we delayed. Hopefully we can start it up again. Made my own RSS Feed - useful? - WillHamilton - 15-08-2006 Again, I'll be honest and admit that I'm not too sure what goes on in the themes and so forth. My method was to just order the zen_images by ID - the highest numbers are the newest images. Grab the top fifteen rows from there and you're away. I've been following your progress on RSS, but I got the impression that you'd been stalled by more complex things like publication dates and multiple albums/feeds etc. Thought I'd just make my own one, since my art area is simple enough. Good luck hammering out all the more difficult parts. Made a cute latest page too: http://bridgetothestars.net/fanart/latest.php Made my own RSS Feed - useful? - thinkdreams - 18-08-2006 Starting up RSS feeds again would be cool Trisweb. I have rudimentary RSS working based on other forum posts, and code patches posted on the wiki. But it lacks extensibility, in the form of latest image feeds, latest album feeds, etc. I simplified the RSS to the point where it validates as a 2.0 RSS feed, and it seems to work well. The images are inserted in the item description tag in the XML using zenphoto functions. I'm fairly happy with it. http://www.thinkdreams.com/zenphoto is the link to peruse if anyone is interested. Please be gentle. I'm learning. Made my own RSS Feed - useful? - thinkdreams - 18-08-2006 One thing I am going to suggest as you move forward in development of Zenphoto RSS capability Trisweb, is that it would be nice to include latest album and images RSS feeds. What I'm wrangling with at the moment is the ability to adapt the RSS feed function I "borrowed" from the forums to display latest images. I'm having a bit of a struggle with it. If anyone has any suggestions that would be cool. What I'm having trouble with right now is where to actually place the feed so it hits the right context to pull images. I'm thinking you should be able to pass "latest.rss" to the browser, and then it should direct to the zenphoto code where to go in the "rss" theme folder. My code is a bit of adaptation from the latest images code on the forums and the RSS code I use for the albums. I'm just not sure how to put it together to make it work properly without screwing up the context. Made my own RSS Feed - useful? - thinkdreams - 18-08-2006 Will- If you don't mind me asking, can I see a copy of your code to see how it was done? Your latest functionality is exactly what I'm trying to do, and I would like to see how yours differs. If you like I'll post my code here so you can do the same. Made my own RSS Feed - useful? - WillHamilton - 19-08-2006 I sent this already through email, but for the benefit of anyone who's interested I'll repeat it here: Bear in mind this is done totally outside of the themes and functions of zenphoto since I felt like writing my own. The RSS feed is styless of course, but you can include the style sheet if you want a latest page with the same aesthetics as your gallery. Let us begin.. First the RSS stuff:
Then open up your images database however you usually do within php - most of this is done with php btw. We select everything from the zen_images table. The fact that it's ordered by descending ID means that the newest images - which have the highest ID - will be at the top.
Put any number you want by the i; that's how many images will be in the RSS. (see later for how this can be used quite flexibly)
Now I had to use a bit of trickery at this point. From the zen_images table we can get that above information for a piece of art - filename, title and desc. I don't know about you, but I just use the 'desc' field for the artist's name; it's rather unfathomable there's no space for it in zenphoto.. Anyway, you can see we're missing the album that the piece of art is in - all we have is the album ID. I'm sure there's a way to cross-reference this with the zen_albums table and get the album title from the album ID, but I couldn't be arsed. I just cheated and put in at this point:
etc. I only have 20 albums, so that's pretty easy - stuck the ifs in an include to get it out the way as well. It depends if you change albums around a lot; if you do it'd be much better to find the album title properly, using the zen_albums table. So to finish and give the output:
Very basic RSS XML - no publication date or anything. It works just fine however. What I've done with this latest-images code is get most of it in includes so the pages it's displayed on are very simple. On my home page for example, where I just want to show the latest image, the code for that is simply: Quite cute. Made my own RSS Feed - useful? - thinkdreams - 19-08-2006 With Will's help, I managed to get it to work pretty well. So now I have a working implementation of a per album RSS feed, and a latest image feed. Here is the link to the latest image feed: http://www.thinkdreams.com/zenphoto/index.php?p=latest in case anyone wishes to take a look. If you are interested in seeing the code, let me know, and I'll share it here. Made my own RSS Feed - useful? - thinkdreams - 21-08-2006 One thing Will noticed with my RSS feed. It always comes up as "index.php". Please see the attached code. I call it from a link to the specific page (http://www.thinkdreams.com/zenphoto/index.php?p=latest), so I can potentially see that it being called as a PHP file, but could anyone shed light on why it's working that way? My goal is to have it work within a browser. The feed validates OK, it just won't display in a browser. `
http://www.thinkdreams.com/zenphoto Latest Images From Thinkdreams en-us ` Made my own RSS Feed - useful? - thinkdreams - 21-08-2006 Looks like I answered my own question. I changed the header designation to: header ('Content-Type: text/xml'); And it works. Guess it didn't like the application/rss+xml header type for some reason... Made my own RSS Feed - useful? - bbish007 - 13-12-2006 I think this is because a lot of modern browsers still don't recognise xHTML media types. Made my own RSS Feed - useful? - piXelatedEmpire - 14-03-2007 Hi thinkdreams Made my own RSS Feed - useful? - thinkdreams - 14-03-2007 I am, but I haven't gotten around to updating it yet. As soon as the EXIF stuff is in progress, I was going to put what I have up there for Tristan to review so he start incorporating that as well. RSS feeds are in for the 1.1 version I believe. My solution was basically a separate page that grabs the images from the DB and displays them. I'm sure there is a more elegant solution. At one time I also had an albums RSS feed, but it required mods to core zenphoto files, and I would rather not have modded the core code too much. Right now, all that is wrong with the code above that I posted is that it may not use the new method for grabbing images from the cache in the newer version of zenphoto. I'll see about updating that to work better when I get a moment. Made my own RSS Feed - useful? - thinkdreams - 14-03-2007 Note also that my solution requires database parameters within the page, so I would want to figure out a better way to handle this from within Zenphoto. Made my own RSS Feed - useful? - thinkdreams - 14-03-2007 I just tested it, http://www.bushwoodworking.com/zenphoto/page/latest and it works fine with SVN rev 418 (latest version on the repo) so it should be just fine. I'm sure there is some tweaking that can be done. I'll put my code up as a ticket attached to the 1.1 milestone, in case Tristan can utilize it for his RSS work. I think the major issue with the current code, is everything is hardcoded, it is placed within the theme (i.e. not universal to all themes) and it requires it's own database username/password parameters, which shouldn't be necessary. Maybe Tristan can take a look and maybe make some suggestions. You'll need to change the title, url, and link for the rss channel and image tags, and hardcode the links under the item tag for your specific install: `
Latest Images From Bushwood Copyright Bushwoodworking.com http://www.creativecommons.org/licenses/by-nc-nd/2.5 en-us
` Made my own RSS Feed - useful? - thinkdreams - 14-03-2007 The code didn't paste so well, so if anyone has issues, let me know. Made my own RSS Feed - useful? - thinkdreams - 14-03-2007 OK. I updated the RSS feed ticket with comments and the code above if any one is interested. Made my own RSS Feed - useful? - Barbara - 09-08-2007 Hey, thanks a lot! Just one question: is it safe to store password and username in this file? Made my own RSS Feed - useful? - thinkdreams - 09-08-2007 I believe someone would have to have access to the web server to download the PHP code to get that info, as it's compiled during web requests, you won't ever see the user/pass in the page source. There may be other ways to get it but it's fairly secure. Made my own RSS Feed - useful? - Alenonimo - 15-08-2007 Hey guys! Check this out. I've tuned the thinkdreams RSS generator to make it more friendly. [b]It works by just puting it in the ZenPhoto directory.[/b] No need to set password, e-mail, gallery name, etc — as you already setted it in the [b]zp-config.php[/b] — not even the URLs — as PHP can figure it out alone. Just save the code as [b]rss.php[/b] at the root of the ZenPhoto, put a link to it on your template and you're ready to go. `
` `
|