Jamroom Logo Jamroom 5 Core
is now Open Source!
User Support Forum Archive (Read Only)
User Documentation and How To's:
RSS, Podcasts, and much, much more ;)
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 08/07/07 09:27 
Oh yeah, sorry, I wasn't even thinking! Try the $song.BAND_TIME variable like you suggested.


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Douglas
Jamroom Team


Joined: 08 Oct 2004
Posts: 6639
Location: Tornado Alley!

Posted: 08/07/07 09:38 

smith.kyle:
Oh yeah, sorry, I wasn't even thinking! Try the $song.BAND_TIME variable like you suggested.


I do that all the time, scary thing is, your too young to be losing your mind. Wink

I haven't tried to validate this yet, wanted to see if Jill thought this would even work for the time stamp.



Quote:
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>{$RADIO_NAME} - Top 40 Feed</title>
<description>{$RADIO_DESCRIPTION}</description>
<language>en-us</language>
<webMaster>you@yoursite.com</webMaster>
<link>{$JAMROOM_URL}</link>
<copyright>{$smarty.now|jr_date_format:"%Y"} {$system_name|escape:"quotes"} All rights reserved.</copyright>
<lastBuildDate>{$smarty.now|jr_date_format:"%a, %d %b %Y %T %Z"}</lastBuildDate>
<ttl>60</ttl>
{foreach from=$RADIO_SONGS key=key item=songs name=song_val}
{$smarty.foreach.song_val.iteration}
<item>
<title>{$songs.SONG_NAME|replace:"&":"&amp;"}</title>
<description><![CDATA[<a href="{$songs.SONG_PLAY_URL}">Click To Listen!</a>&nbsp;&nbsp;{$songs.SONG_NAME|replace:"&":"&amp;"} - By: {$songs.BAND_NAME|replace:"&":"&amp;"}<br>
]]></description>
<pubDate>{$songs.BAND_TIME|jr_date_format:"%D, %j %M %Y %H %i %s %T"}</pubDate>
</item>

{/foreach}
</channel>
</rss>



_________________
Douglas Hackney
Jamroom Network Team Member: http://www.jamroom.net
Priority Support: http://www.jamroom.net/Support_Center
Back to top
jp



Joined: 05 Jan 2006
Posts: 495
Location: Ohio

Posted: 08/07/07 14:03 

Quote:
Try the $songs.BAND_TIME variable

I worked with this some this morning again, but the problem with any of the time stamp variables I can pull is that they aren't sending any time over to the XML, so the <pubDate> field remains blank. (Also, I can't find documentation on the BAND_TIME variable at all - is this a song template variable or a band template variable?)

I also tried $songs.SONG_CREATE, with the time stamp conversion, but still no dice. Not quite sure why the variables aren't pulling any information over, even if it ends up in the incorrect format. I also tried the various $SONG_DATE variables and can't get information to pull into the template, either.

Part of this is that I don't actually under stand what the format of $songs.SOME_VARIABLE does within the code. Is the $songs. part there to make a variable available that would not normally be available in the radio playlist template?

I'll hope to pick away at it a little more tonight when I get home from work, but I've got about 43 unanswered emails from bands that I need to take care of, so I'm not sure I'll have time to work on it.

The {$return_email} works great (I knew there was something for that, and was just being lazy not looking it up! BUT, a feed e-mail address can get heavily spammed, so site owners might not want it to be the same address they use for support functions, etc.

Jill

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 08/07/07 14:36 
I think it's the foreach loop that's confusing you. Basically, the playlist.php file creates an array of songs in the playlist called RADIO_SONGS. Each element of the array in RADIO_SONGS is actually an array itself. Here's a more visual example:


Code
RADIO_SONGS -> array (
        $song1 -> array (
              SONG_PLAY_URL = "http:etc.etc.";
              SONG_NAME = "Song Name"
              )
        $song2 -> array (
              SONG_PLAY_URL = "http2:etc.etc.";
              SONG_NAME = "Song Name2"
              )
        )


So the foreach loops over each $song in the RADIO_SONGS array, and the elements after the . are just variables particular to each song. Hopefully that makes sense. I'd suggest doing a {debug output="html"} in this template as well to see a full display of the variables, it'll also help you understand it (arrays were WAY over my head until I started learning php, now I can't live without em! Wink )

Hope that helps!

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 08/07/07 16:21 
Let me know how this works out for you guys:


Code
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>{$RADIO_NAME} - Top 40 Feed</title>
<description>{$RADIO_DESCRIPTION}</description>
<language>en-us</language>
<webMaster>you@yoursite.com</webMaster>
<link>{$JAMROOM_URL}</link>
<copyright>{$smarty.now|jr_date_format:"%Y"} {$system_name|escape:"quotes"} All rights reserved.</copyright>
<lastBuildDate>{$RADIO_TIME|date_format:"%a, %d %b %Y %T %Z"}</lastBuildDate>
<ttl>60</ttl>
{foreach from=$RADIO_SONGS key=key item=songs name=song_val}
{$smarty.foreach.song_val.iteration}
<item>
<title>{$songs.SONG_NAME|replace:"&":"&amp;"}</title>
<description><![CDATA[<a href="{$songs.SONG_PLAY_URL}">Click To Listen!</a>&nbsp;&nbsp;{$songs.SONG_NAME|replace:"&":"&amp;"} - By: {$songs.BAND_NAME|replace:"&":"&amp;"}<br>
]]></description>
<pubDate>{$songs.SONG_TIME|date_format:"%a, %d %b %Y %T %Z"}</pubDate>
</item>

{/foreach}
</channel>
</rss>



_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 08/07/07 16:49 
I tried validating the feed, and it didn't validate. I know how one of the errors (with a template pre-processor), and think I know how to fix the second, but not the third. Try doing this:

create podcast.tpl.php:

Code
<?php
// These header calls are required to get the browser to see this as an RSS Feed
header('Expires: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
header('Last-Modified: '. gmdate('D, d M Y H:i:s') .' GMT');
header('Content-Type: application/xml; charset=utf-8');
?>


Then in podcast.tpl:

Code
{jr_playlist id="1" limit="40" template="podcast_xml.tpl"}


And then podcast_xml.tpl:

Code
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>{$RADIO_NAME} - Top 40 Feed</title>
<description>{$RADIO_DESCRIPTION}</description>
<language>en-us</language>
<webMaster>you@yoursite.com</webMaster>
<link>{$JAMROOM_URL}</link>
<copyright>{$smarty.now|jr_date_format:"%Y"} {$system_name|escape:"quotes"} All rights reserved.</copyright>
<lastBuildDate>{$RADIO_TIME|date_format:"%a, %d %b %Y %T %Z"}</lastBuildDate>
<ttl>60</ttl>
{foreach from=$RADIO_SONGS key=key item=songs name=song_val}
{$smarty.foreach.song_val.iteration}
<item>
<title>{$songs.SONG_NAME|replace:"&":"&amp;"}</title>
<description><![CDATA[<a href="{$songs.SONG_PLAY_URL}">Click To Listen!</a>&nbsp;&nbsp;{$songs.SONG_NAME|replace:"&":"&amp;"} - By: {$songs.BAND_NAME|replace:"&":"&amp;"}<br>
]]></description>
<pubDate>{$songs.SONG_TIME|date_format:"%a, %d %b %Y %T %Z"}</pubDate>
</item>

{/foreach}
</channel>
</rss>


The second thing the feed validator complains about is this line:

{$smarty.foreach.song_val.iteration}

My guess is because it's not in any xml tags.

The last thing has to do with the </item> lines, and this is the error I get:

item should contain a guid element

-Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
jp



Joined: 05 Jan 2006
Posts: 495
Location: Ohio

Posted: 08/08/07 13:49 

Quote:
So the foreach loops over each $song in the RADIO_SONGS array, and the elements after the . are just variables particular to each song. Hopefully that makes sense. I'd suggest doing a {debug output="html"} in this template as well to see a full display of the variables

Thanks for the explanation, Kyle - now that you explained it's an array, I have a better understanding of that. I know what arrays do, but apparently don't recognize one when I see one! And no way could I write them. I'm pretty thrilled that I can usually get an if/else statement to work.


Quote:
The second thing the feed validator complains about is this line:

{$smarty.foreach.song_val.iteration}

My guess is because it's not in any xml tags.

That won't come through in the parsed code, so it shouldn't be a problem for the validation of the xml.


Quote:
item should contain a guid element

I tried to put the <guid> in, but had difficulties figuring what to use - it should be the link to the item, but that didn't work out (perhaps because it was three in the morning when I was working on it?). However, it doesn't have to be, so I will probably look to put another unique variable in there. Some feed readers will use <guid>, but it is optional because if it isn't there, they will use the item date. However, it's always best to use it when you can.

I didn't have time to work on this tonight, but I should have time tonight. We'll see how the $songs.SONG_TIME works out for the time stamping and I'll let you know.

Jill

Back to top
jp



Joined: 05 Jan 2006
Posts: 495
Location: Ohio

Posted: 08/08/07 22:27 
Well, I'm feeling rather discouraged. The feed finally validates as RSS and works correctly. In FireFox. In IE, it does not access it as a feed.

Brian gets around this with an RSS/XML wrapper which work really great with the other feeds I built which only serve up text. I tried wrapping this one in it, and I can't get it to work.

The final code does not have the numbering provided by{$smarty.foreach.song_val.iteration}. Kyle, you are correct that it won't validate because it isn't inside an element.

The dates work great with a small tweak.

Here is the code:


Code

<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>{$RADIO_NAME} - Top 40 Feed</title>
<description>{$RADIO_DESCRIPTION}</description>
<language>en-us</language>
<webMaster>{$return_email}</webMaster>
<link>{$JAMROOM_URL}</link>
<copyright>{$smarty.now|jr_date_format:"%Y"} {$system_name|escape:"quotes"} All rights reserved.</copyright>
<lastBuildDate>{$smarty.now|jr_date_format:"%a, %d %b %Y %T"} -0500</lastBuildDate>
<ttl>60</ttl>
{foreach from=$RADIO_SONGS key=key item=songs name=song_val}
<item>
<title>{$songs.SONG_NAME|replace:"&":"&amp;"}</title>
<description><![CDATA[<a href="{$songs.SONG_PLAY_URL}">Click To Listen!</a>&nbsp;&nbsp;{$songs.SONG_NAME|replace:"&":"&amp;"} - By: {$songs.BAND_NAME|replace:"&":"&amp;"}<br>
]]></description>
<pubDate>{$songs.SONG_TIME|date_format:"%a, %d %b %Y %T"} -0500</pubDate>
<guid isPermaLink="false">{$songs.SONG_NAME|replace:"&":"&amp;"}</guid>
</item>

{/foreach}
</channel>
</rss>


If someone can get that to be seen as RSS/XML it will work fine. Like I said, works great in FireFox. I took out the php and put the basics into Brian's wrapper and it goes horribly wrong with an xml parsing error.

I can't really any farther with this with what I know. The RSS is good and is working, but I don't how to get it to be seen as an RSS file. I tried basically taking out the php statements and using Brian's wrapper for it by breaking the heading, items, and footer out into tpls, but it didn't even get close to generating RSS code.

Jill

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 08/08/07 22:30 
Are you using that on your system Jill? Would you mind if I logged in as your admin and tried some things out with it?


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
jp



Joined: 05 Jan 2006
Posts: 495
Location: Ohio

Posted: 08/08/07 22:45 

Quote:
Are you using that on your system Jill? Would you mind if I logged in as your admin and tried some things out with it?

Kyle, I would have no problem with giving you my admin, but the only thing I put on the live site was the parsed code I pulled out of the source on my local test site so that I could see if it validated. My live site is still running on V2 while I'm trying to get the new site done.

You could grab the code and put it on your demo site - if you have a station set up and stick the link somewhere, that would let you mess with it.

Jill

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 08/08/07 23:00 
Try this on for size:

http://kyle.jamroom.net/index.php?t=podcast

Wink Lemme know if that works and I'll show you what I did.


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
jp



Joined: 05 Jan 2006
Posts: 495
Location: Ohio

Posted: 08/08/07 23:17 

Quote:
Try this on for size:

http://kyle.jamroom.net/index.php?t=podcast

Lemme know if that works and I'll show you what I did.

Well, of course it works. I spend a couple of hours trying to figure it out and you have it in five minutes. Sigh.

Okay, what was the secret?

Jill

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 08/08/07 23:22 
I put the code you made in a template called podcast_xml.tpl in my skins/Cobalt3 directory. Then, I created another template, podcast.tpl:


Code

{jr_playlist id="1" limit="40" template="podcast_xml.tpl"}


And then I used the new template pre-processor functionality in a template called podcast.tpl.php:

create podcast.tpl.php:


Code

<?php
// These header calls are required to get the browser to see this as an RSS Feed
header('Expires: '. gmdate('D, d M Y H:i:s', time()) .' GMT');
header('Last-Modified: '. gmdate('D, d M Y H:i:s') .' GMT');
header('Content-Type: application/xml; charset=utf-8');
?>


(it's actually almost the same as my post above: http://www.jamroom.net/phpBB2/viewtopic.php?p=87310#86905 )

I think that the RSS wrapper in the docs could actually be re-written to use the preprocessor as well, so it's pretty cool!

Glad we nailed this one down! Good job! Very Happy

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
jp



Joined: 05 Jan 2006
Posts: 495
Location: Ohio

Posted: 08/08/07 23:32 
Clearly, in all this I missed that original explanation. I was too focused on making the RSS elements validate.

But I am still a bit confused...not sure how that all links up or which one is used for the link to the feed. This is because I have lost all ability to process information and need to get to bed. Hopefully, it will all make perfect sense tomorrow morning.

Thanks, Kyle!

Jill

Back to top
smith.kyle
CodeSmith


Joined: 27 Apr 2006
Posts: 22009
Location: Southern California

Posted: 08/08/07 23:36 
Jamroom 3.1 has the ability to use template pre-processors, meaning that if jamroom finds a file with the same name as the template being called, but with a .php extension, it will execute the .php file first before the .tpl file.

So in this case, the two files are podcast.tpl, and podcast.tpl.php . Since Jamroom sees the podcast.tpl file has a template pre-processor (podcast.tpl.php), it processes that file first (which must be written in php). I put the raw header functions in their, so they get processed before the podcast.tpl.

Long of the short story is that you just call the podcast.tpl file via the index.php, i.e.

http://kyle.jamroom.net/index.php?t=podcast

or

http://kyle.jamroom.net/index.php?template=podcast.tpl

Make sense?

Kyle


_________________
kyle[at]jamroom.net

Yes...that's a soda machine...

I get bored when no one's posting...
Back to top
Display posts from previous:   
User Support Forum Archive (Read Only)
User Documentation and How To's

< Previous12345Next >
 
Solutions
• Social Media Platform
• Social Networking Software
• Musician Website Manager
• Community Builder
Products
• Jamroom Core
• Jamroom Addons
• Jamroom Modules
• Jamroom Marketplace
Support
• Support Forum
• Documentation
• Support Center
• Contact Support
Community
• Community Forum
• Member Sites
• Developers
Company
• About Us
• Contact Us
• Privacy Policy
©2003 - 2010 Talldude Networks, LLC.