views:

412

answers:

2

After a couple hours fighting with the Gallery2 RSS module and getting only the message, "no feeds have yet been defined", I gave up. Based on a Google search for "no feeds have yet been defined", this is a pretty common problem. Do you have any tips and/or tricks for getting the Gallery2 RSS module to work? Or any tips for a relatively-PHP-ignorant developer trying to debug problems with this PHP application?

+1  A: 

My eventual (and hopefully temporary) solution to this problem was a Python CGI script. My script follows for anyone who might find it useful (despite the fact that this is a total hack).

#!/usr/bin/python
"""A CGI script to produce an RSS feed of top-level Gallery2 albums."""

#import cgi
#import cgitb; cgitb.enable()
from time import gmtime, strftime
import MySQLdb

ALBUM_QUERY = '''
    select g_id, g_title, g_originationTimestamp
    from g_Item
    where g_canContainChildren = 1 
    order by g_originationTimestamp desc
    limit 0, 20
    '''

RSS_TEMPLATE = '''Content-Type: text/xml

<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>TITLE</title>
    <link><http://example.com/gallery2/main.php&gt;&lt;/link&gt;
    <description>DESCRIPTION</description>
    <ttl>1440</ttl>
%s
  </channel>
</rss>
'''

ITEM_TEMPLATE = '''
    <item>
      <title>%s</title>
      <link><http://example.com/gallery2/main.php?g2_itemId=%s&gt;&lt;/link&gt;
      <description>%s</description>
      <pubDate>%s</pubDate>
    </item>
'''

def to_item(row):
    item_id = row[0]
    title = row[1]
    date = strftime("%a, %d %b %Y %H:%M:%S GMT", gmtime(row[2]))
    return ITEM_TEMPLATE % (title, item_id, title, date)

conn = MySQLdb.connect(host = "HOST",
                       user = "USER",
                       passwd = "PASSWORD",
                       db = "DATABASE")
curs = conn.cursor()
curs.execute(ALBUM_QUERY)
print RSS_TEMPLATE % ''.join([ to_item(row) for row in curs.fetchall() ])
curs.close()
ESV
A: 

Well, I am unsure this can help you but here is a very simple RSS that was presented as solution in another topic:

PHP RSS Builder

Veynom