I am working on implementing jplayer on my site and need to generate the playlist in php. I’ve pretty much got comma seperation worked out, but the call i use to get my song url and song title are causing php errors and Im not quite sure what Im doing wrong. Im using social engine an extension of zend. I am normally able to use <?php echo $this->string()->truncate($song->getTitle(), 50) ?> and <?php $current_url = explode('?', $song->getFilePath()); to generate my mp3 title and url without a problem within the for each loop. My code is below, can someone point me in the right direction?
echo $current_url[0]; ?>
<?php
$count = 0;
foreach( $songs as $song => $item): if( !empty($song) ): ?>
<?php if ( $count ) { print ", "; } $count++; ?>
{
title:"<?php echo $this->string()->truncate($song->getTitle(), 50) ?>",
mp3:"<?php $current_url = explode('?', $song->getFilePath());
echo $current_url[0]; ?>"
}
<?php endif; endforeach; ?>
edit: the error im seeing is “Call to a member function getTitle() on a non-object in …player.tpl “
you’re using
$songinside of your loop where you should use$item.$songis only the array-key, so there no method calledgetTitlewhile$itemis your actual object.