solved RSS Template Variables

michaeld
michaeld
@michael-d
5 years ago
92 posts
So I've been editing my Rss.tpl file

I've been able to call all the variables I need in the {for each} loop!! Audio data, profile data, etc

However, calling these variables from outside the {for each} loop will not work.

How can we fix this?




--
Thank You
~Michael
Audio Engineer | Graphic and Design |

https://www.damatoproduction.com
https://www.HomeStudioMusicProduction.com
https://www.ShotsInOrder.com
https://www.playgroundz.rocks

updated by @michael-d: 11/25/19 08:02:57PM
michael
@michael
5 years ago
7,740 posts
You use a foreach loop to loop over the elements in an array, so if you have an array like this:
$the_array = array('cat', 'dog', 'ant eater');
then a foreach loop over it would go
{foreach $_the_array as $animal}
The animal is a {$animal}
{/foreach}

But if your array looks like this
$the_array = array('tom' => 'cat', 'bill' => 'dog', 'simon' => 'ant eater');
Then the foreach loop would look like this

{foreach $_the_array as $owner => $pet}
The pet of {$owner} is a {$pet}
{/foreach}

So it depends on what your array looks like as to how you access it outside a loop.

For the second array you can go
the pet of Simon is a {$the_array['simon']}
or
the pet of Simon is a {$the_array.simon}

to get Simons pet.
updated by @michael: 08/22/19 10:16:57PM
michaeld
michaeld
@michael-d
5 years ago
92 posts
Thank you...but my question is related to the variables I have access to in the rss.tpl file

Some variables work in just part of this file, and not in the other part of the file.

How can we fix this?


--
Thank You
~Michael
Audio Engineer | Graphic and Design |

https://www.damatoproduction.com
https://www.HomeStudioMusicProduction.com
https://www.ShotsInOrder.com
https://www.playgroundz.rocks

updated by @michael-d: 08/23/19 06:17:40AM
michaeld
michaeld
@michael-d
5 years ago
92 posts
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
   
    <channel>
        <title><![CDATA[{$rss_title}]]></title>
        <description>This is the {$rss_title} podcast<![CDATA[{$rss_desc}]]></description>
        <link>{$rss_url}</link>
        <image>
           <url>http://www.playgroundz.rocks/webhosting/profile/image/profile_image/{$item._profile_id}/original</url>
           <title>Playgroundz.rocks</title>
           <link>https://www.playgroundz.rocks</link>
        </image>
        <lastBuildDate>{$rss_builddate}</lastBuildDate>
        <atom:link href="{$rss_feed_url}" rel="self" type="application/rss+xml" />
        
        
        {foreach $_items as $item}
            <item>
                <title><![CDATA[{$item.title}]]></title>
                <link>{$item.link}</link>
                <enclosure url="http://www.playgroundz.rocks/webhosting/audio/stream/audio_file/{$item._item_id}" length="{$item.audio_file_size}" type="audio/mpeg"/>
                <guid>{$item.guid}</guid>
                <description><![CDATA[{$item.description}]]></description>
                <pubDate>{$item.pubdate}</pubDate>
            </item>
        {/foreach}
    </channel>
</rss>

I can only access datastore variables for audio, profiles, etc... in the bottom half of this file, but not the top half(outside the loop)

More specifically I am trying to call images inside the image tag....but I dont have access to the variables for profile_image, or song_image in that part of the file


--
Thank You
~Michael
Audio Engineer | Graphic and Design |

https://www.damatoproduction.com
https://www.HomeStudioMusicProduction.com
https://www.ShotsInOrder.com
https://www.playgroundz.rocks

updated by @michael-d: 08/23/19 06:31:34AM
michael
@michael
5 years ago
7,740 posts
What variables you have available in a template can be discovered with {debug}

Docs: "{debug}"
https://www.jamroom.net/the-jamroom-network/documentation/module-developer-guide/1477/debug
michaeld
michaeld
@michael-d
5 years ago
92 posts
I already tried debug on the rss.tpl file and it doesn't work.

Why would some variables only be available to part of the file and not the entire file?




--
Thank You
~Michael
Audio Engineer | Graphic and Design |

https://www.damatoproduction.com
https://www.HomeStudioMusicProduction.com
https://www.ShotsInOrder.com
https://www.playgroundz.rocks

updated by @michael-d: 08/23/19 07:31:00PM
michael
@michael
5 years ago
7,740 posts
Things are getting to cryptic for me, im not understanding. What do you want to get into the rss.tpl file?

You want to get the profile info out.

Could you post your ideal RSS structure here along with the current structure and what info you need. Cheers.

--edit--
and whats the URL (or example of) that you're accessing the rss on. is it the main site feed or a profile.
updated by @michael: 08/23/19 08:16:57PM
michaeld
michaeld
@michael-d
5 years ago
92 posts
So it’s for the profile audio feeds...

I want to call a profile or song image
As the main image for a podcast
This needs needs to be in the upper half of the rss file, but these variables don’t work

However, the same variables work in the bottom half of the rss file....

Bottom half starting at where the for each loop is.


--
Thank You
~Michael
Audio Engineer | Graphic and Design |

https://www.damatoproduction.com
https://www.HomeStudioMusicProduction.com
https://www.ShotsInOrder.com
https://www.playgroundz.rocks
michael
@michael
5 years ago
7,740 posts
try:
{$item.0._profile_id}
michaeld
michaeld
@michael-d
5 years ago
92 posts
So that does not work...It will not read parse these variables in the top half of the file

This is how it looks when its parsed/read....look at the url tag inside the image tag.....

<rss version="2.0"><channel><title>@Shots In Order - audio</title>
<description>This is the @Shots In Order - audio podcast</description>
<link>http://www.playgroundz.rocks/webhosting/shotsinorder</link>
<image>
<url>http://www.playgroundz.rocks/webhosting/profile/image/profile_image//original</url><title>W3Schools.com</title>
<link>https://www.w3schools.com</link>
</image>
<lastBuildDate>Sun, 25 Aug 2019 15:22:44 -0400</lastBuildDate>
<atom:link href="http://www.playgroundz.rocks/webhosting/feed/audio/shotsinorder" rel="self" type="application/rss+xml"/>
<item>
<title>devotion - @shotsinorder</title>
<link>http://www.playgroundz.rocks/webhosting/shotsinorder/audio/1414/devotion</link>
<enclosure url="http://www.playgroundz.rocks/webhosting/audio/stream/audio_file/1414" length="5335168" type="audio/mpeg"/>
<guid>http://www.playgroundz.rocks/webhosting/shotsinorder/audio/1414</guid>
<description>Shots In Order Posted a new Audio File - "devotion"</description><pubDate>Mon, 19 Aug 2019 23:03:04 -0400</pubDate>
<image>
<url>http://www.playgroundz.rocks/webhosting/profile/image/profile_image/2/original</url><title>W3Schools.com</title>
<link>https://www.w3schools.com</link>
</image>
</item>
<item>
<title>Call A Spade - @shotsinorder</title>
<link>http://www.playgroundz.rocks/webhosting/shotsinorder/audio/1/call-a-spade</link>
<enclosure url="http://www.playgroundz.rocks/webhosting/audio/stream/audio_file/1" length="7811200" type="audio/mpeg"/>
<guid>http://www.playgroundz.rocks/webhosting/shotsinorder/audio/1</guid>
<description>Shots In Order Posted a new Audio File - "Call A Spade"</description><pubDate>Mon, 04 Jun 2018 13:17:52 -0400</pubDate>
<image>
<url>http://www.playgroundz.rocks/webhosting/profile/image/profile_image/2/original</url><title>W3Schools.com</title>
<link>https://www.w3schools.com</link>
</image>
</item>
</channel>
</rss>



--
Thank You
~Michael
Audio Engineer | Graphic and Design |

https://www.damatoproduction.com
https://www.HomeStudioMusicProduction.com
https://www.ShotsInOrder.com
https://www.playgroundz.rocks

updated by @michael-d: 08/25/19 12:33:44PM
michael
@michael
5 years ago
7,740 posts
Try:
$_items[0]._profile_id
michaeld
michaeld
@michael-d
5 years ago
92 posts
Worked great!! Thank you for your time and work!!!


--
Thank You
~Michael
Audio Engineer | Graphic and Design |

https://www.damatoproduction.com
https://www.HomeStudioMusicProduction.com
https://www.ShotsInOrder.com
https://www.playgroundz.rocks

Tags