Previous Song - Random Song - Next Song Buttons
How can I program this?
{{item.number -1}} {{item.number random1-365}} {{item.number +1}} ???
Previous Song - Random Song - Next Song Buttons
How can I program this?
{{item.number -1}} {{item.number random1-365}} {{item.number +1}} ???
Elements Bot created this will try tomorrow…
Button Code
<php>
// Assuming $cms is your CMS instance
$randomIndex = array_rand($cms->items());
$randomSong = $cms->items()[$randomIndex];
// This adds Tailwind CSS classes for styling
echo '<a href="' . $randomSong->url() . '" class="bg-blue-500 text-white p-2 rounded">Random Song: ' . htmlentities($randomSong->title()) . '</a>';
</php>
<php>
// Assuming $cms is your CMS instance and $currentSong is the current song object
$currentSongIndex = array_search($currentSong, $cms->items());
if ($currentSongIndex !== false && $currentSongIndex > 0) {
$previousSong = $cms->items()[$currentSongIndex - 1];
// This adds Tailwind CSS classes for styling
echo '<a href="' . $previousSong->url() . '" class="bg-blue-500 text-white p-2 rounded">Previous Song: ' . htmlentities($previousSong->title()) . '</a>';
}
</php>
<php>
// Assuming $cms is your CMS instance and $currentSong is the current song object
$currentSongIndex = array_search($currentSong, $cms->items());
if ($currentSongIndex !== false && $currentSongIndex < count($cms->items()) - 1) {
$nextSong = $cms->items()[$currentSongIndex + 1];
// This adds Tailwind CSS classes for styling
echo '<a href="' . $nextSong->url() . '" class="bg-blue-500 text-white p-2 rounded">Next Song: ' . htmlentities($nextSong->title()) . '</a>';
}
</php>
At the moment this isn’t possible. We’d need to extend the CMS Item with additional properties and/or introduce new components to handle this kind of navigation, similar to how Related Items works.
Thanx for responding! I really appreciate it …
I’m trying to solve the problems as best as I can…
Ok - will wait…