Tutorials: Highlighting non-empty alphabet listing in XoopsTube
Posted by: MambaOn 2013/6/17 0:40:00 6384 readsIn XoopsTube we have a visual alphabetical listing of videos, so if you would like to see all videos starting with "B" you would click on the image with "B". Unfortunately, this is not the most user-friendly feature, because we don't know if there is anything under "B". So we needed to indicate the existence of videos by a changed background icon, as you can see below:

$distinctDbLetters_arr = array();
$sql = 'SELECT DISTINCT (UPPER(LEFT(title, 1))) AS letter FROM ' . $xoopsDB->prefix('xoopstube_videos') ;
if ($result = $xoopsDB->query($sql)) {
while ($row = $xoopsDB->fetchArray($result)) {
$distinctDbLetters_arr[] = $row['letter'];
}
}
unset($sql);
if (in_array($ltr, $distinctDbLetters_arr)) {
$letterchoice
.= ';
} else {
$letterchoice
.= ';
}
.xoopstube_letters_green {
background-image: url(images/icon/backgnd_green.png);
}