WordPress.org

Ready to get started?Download WordPress

Forums

Repeating Videos (1 post)

  1. danielmichel
    Member
    Posted 1 year ago #

    This seems to be repeating the list of youtube videos 3 or 4 times.

    <div class="atv-row">
    	<ul class="demo4">
    		<?php
    		for ($i=0; $i<=10; $i++) { ?>
    		<?php
    		$playlistFeedURL = 'http://gdata.youtube.com/feeds/api/playlists/PL6549D4CA7BB99B16?v=2';
    		$sxml = simplexml_load_file($playlistFeedURL);
    		foreach ($sxml->entry as $entry) {
    		$media = $entry->children('http://search.yahoo.com/mrss/');
    		$attrs = $media->group->player->attributes();
    		$watch = $attrs['url'];
    		$attrs = $media->group->thumbnail[0]->attributes();
    		$thumbnail = $attrs['url'];
    		$desc = $media->group->description;
    		$yt = $media->children('http://gdata.youtube.com/schemas/2007');
    		$attrs = $yt->duration->attributes();
    		$length = $attrs['seconds'];
    		$yt = $media->children('http://gdata.youtube.com/schemas/2007');
    		$playlistVideoID = $yt->videoid;
    		$yt = $entry->children('http://gdata.youtube.com/schemas/2007');
    		$attrs = $yt->statistics->attributes();
    		$viewCount = $attrs['viewCount'];
    		$gd = $entry->children('http://schemas.google.com/g/2005');
    		if ($gd->rating) {
    		$attrs = $gd->rating->attributes();
    		$rating = $attrs['average'];
    		} else {
    		$rating = 0;
    		}
    		?>
    		<li class="atv-thumbnailwrapper">
    			<a rel="<?php echo $desc; ?>" title="<?php echo $media->group->title; ?>" href="<?php echo $watch; ?>" alt="<?php $watchit = substr($watch, 0, -29); $lastw = str_replace('watch?v=','v/',$watchit); echo $lastw; ?>" ><img class="ytthumb" src="<?php echo $thumbnail;?>" /></a>
    			<span class="text_wrap">
    				<h5><?php echo $media->group->title; ?></h5>
    				<p class="yt_desc"><?php echo $desc; ?></p>
    			</span>
    		</li>
    		<?php
    		}
    		?>
    		<?php } ?>
    	</ul>
    </div>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags