I am trying to create groups of links broken down by the first letter.
So -
A
Apple
Amsterdam
Aluminium
Abracadabra
B
Burger
Black
Banter
Etc.
The second thing is not to show anything if there are no entries beginning with that letter.
I tried to adapt Ray’s SQL but I am a bit lost -
<?php
global $DB;
$gletter='_';
$x = '';
for ($i=65; $i<=90; $i++) { // For lowercase letters, use the numbers 97-122 instead
$x = chr($i);
if ($gletter<>substr($x,0,1)) {
$gletter=substr($x,0,1);
$results = $DB->query("SELECT COUNT(*) as number FROM exp_weblog_titles WHERE weblog_id = 2 AND title LIKE '$gletter%' LIMIT 1;");
$count = $results->row['number'];
if ($count > 0) {
echo '{exp:weblog:entries weblog="artists" orderby="title|artists_first_names" sort="asc"}
<div class="ddmcc">
<ul>
'.$gletter.'
<ul>
<li><a href="http://{url_title_path=">{title}, {artists_first_names}</a></li>
</ul>
</ul>
</div> <!-- ddmcc -->
{/exp:weblog:entries}';
} else {
echo '<li>'.$gletter.'</li>';
}
}
}
?>
But this just spits out all the entries each time a first letter is matched with any of the entries.