Closed mrbrainz closed 10 years ago
I'm having a little trouble following the php templating, but if this is the only plangular instance on the page, you could try checking the loop index against player.i
rather than the track object itself.
Sorry man. I did kind of go all on the copy/paste there.
So in the v-class I'm adding $i which is an integer that starts at 0 and increments on every loop. There's multiple Plangular instances on the page, both tracks and playlists. So I need to reference now playing within this one instance of a Plangular player with playlist.
I DM'd you a link to the project on SoundCloud you're interested.
<ul class="playlist-tracklist">
<?php $i = 0; foreach($trackmetadata['tracks'] as $playlistitem) : ?>
<li class="tracklist-item"><a href="javascript:void(0)" id="playlist-item-<?php echo $i+1; ?>" class="playlist-item" v-on="click: playPause(<?php echo $i; ?>);" v-class="player.currentTrack == tracks.<?php echo $i; ?> ? 'now-playing' : ''">
<span class="trackno"><?php echo $i+1; ?>.</span>
<span class="artist"><?php echo htmlentities($playlistitem->user->username);?></span> -
<span class="tracktitle"><?php echo htmlentities($playlistitem->title);?></span>
</a>
</li> <?php $i++; endforeach; ?></ul>```
FYI I found a workaround. I hard-coded the track ID to match against. It now works!
v-class="player.currentTrack.id == '<?php echo $playlistitem->id; ?>' ? 'now-playing' : ''"
Hi,
I'm outputting a tracklist on a playlist with PHP so I can get individual data on each track (mainly to see if the user has liked the track before). I can't work out the syntax to add a class for "Now Playing"
This is the code I'm using
It's obviously this bit here that's not working:
v-class="player.currentTrack == tracks.<?php echo $i; ?> ? 'now-playing' : ''"
Is there a syntax that I can achieve what I want using the PHP increment rather than Vue's one?
Thanks,
Greg