MyBB Community Forums

Full Version: create a template variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

What I want to do is take the following code
$id= $_GET['youtube_vid'];
// get the feed using magpieRSS
include('rss_fetch.inc');
$feed = fetch_rss("http://gdata.youtube.com/feeds/api/users/arawlifestlye/uploads?alt=rss");
$found = false;
foreach ($feed->items as $item){
	if(strstr($item['guid'], $id)){
		$found = true;
		break;
	}
}

if($found){
	$video = $item;
	?>
	<div class="video">
		<h3><?= ucfirst($video["title"]) ?></h3>
		<p><strong>Date :</strong> <?= date("d-m-Y", strtotime($video['pubdate']) ) ?></p>
		<p>
			<a href="http://www.youtube.com?v=<?= $id ?>">View it on YouTube</a><br />
		</p>
		<p><?= $video["description"] ?></p>
		<div class="object">
			<object width="425" height="350">
				<param name="movie" value="http://www.youtube.com/v/<?= $id ?>">
				</param>
				<embed src="http://www.youtube.com/v/<?= $id ?>" type="application/x-shockwave-flash" width="425" height="350"></embed>
			</object>
		</div>
	</div>
	<?php
}else{
	echo "<h3>No Videos Found</h3>";
}

and make it become {$youtuberss}

so that I can enter it in a specific location in my theme.

Thank you for help.

Derrick

Install Template Conditionals plugin, then you'll be able to use PHP in templates.
http://community.mybb.com/thread-31860.html
(2011-03-14, 06:12 AM)Yaldaram Wrote: [ -> ]Install Template Conditionals plugin, then you'll be able to use PHP in templates.
http://community.mybb.com/thread-31860.html


Thank you for the post, I will look at it, I was thinking more of the lines of maybe it acting more like a plugin itself and wasnt sure how to do it. Ill give that link a look though.

thank you for the help

Derrick

Most welcome Wink