I modified the sort cell in a theme I picked up from DaMysterious. I made it into a drop down menu so that the text wouldn't run off of the top of the table. I would like to know how I can setup my drop down menu to automatically select the default sort order that I have in my CPG configuration.
Thank you.
// HTML template for title row of the thumbnail view (album title + sort options)
if (!isset($template_thumb_view_title_row)) { //{THEMES}
$template_thumb_view_title_row = <<<EOT
<table width="100%" cellpadding="4" cellspacing="0">
<tr>
<td width="100%" class="statlink"><h2>{ALBUM_NAME}</h2></td>
<td><img src="images/spacer.gif" width="1" alt="" /></td>
<td class="sortorder_cell">
<form name="sort">
<select name="sortbox" OnChange="location.href=sort.sortbox.options[selectedIndex].value">
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=ta">{TITLE} +</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=td">{TITLE} -</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=na">{NAME} +</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=nd">{NAME} -</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=da">{DATE} +</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=dd">{DATE} -</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=pa">{POSITION} +</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=pd">{POSITION} -</option>
</select>
</form>
</td>
</tr>
</table>
EOT;
} //{THEMES}
I changed it to this for now:
// HTML template for title row of the thumbnail view (album title + sort options)
if (!isset($template_thumb_view_title_row)) { //{THEMES}
$template_thumb_view_title_row = <<<EOT
<table width="100%" cellpadding="4" cellspacing="0">
<tr>
<td width="100%" class="statlink"><h2>{ALBUM_NAME}</h2></td>
<td><img src="images/spacer.gif" width="1" alt="" /></td>
<td class="sortorder_cell">
<form name="sort">
<select name="sortbox" OnChange="location.href=sort.sortbox.options[selectedIndex].value">
<option>Sorting Order</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=ta">{TITLE} +</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=td">{TITLE} -</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=na">{NAME} +</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=nd">{NAME} -</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=da">{DATE} +</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=dd">{DATE} -</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=pa">{POSITION} +</option>
<option value="thumbnails.php?album={AID}&page={PAGE}&sort=pd">{POSITION} -</option>
</select>
</form>
</td>
</tr>
</table>
EOT;
} //{THEMES}
Perform a check against $CONFIG['default_sort_order']
Don't forget to make that array global first inside a function.
Are you actually populating the placeholder tokens in theme_display_thumbnails() or is above code just wishfull thinking?
Thanks, I'll give that a try.
Quote from: Joachim Müller on March 18, 2009, 07:34:13 AM
Are you actually populating the placeholder tokens in theme_display_thumbnails() or is above code just wishfull thinking?
The code works exactly as I hoped. See here: www.loopfamily.net/CPG/ You can see it work on any gallery.
Works as expected, thanks. Looks promising - you might consider to post your entire mod for the benefit of others.
That is my entire mod, with the exception of a slight change I made to the stylesheet.css to get the drop down menu to line up a bit cleaner.
I have never written anything in PHP and don't know anything about it. I am willing to post this mod to help others, but I would first like to make it display the sorting order used (i.e. the default sort order).
I have tried using the following code to display the the default sort order, but it's not working.
<form name="sort">
$sortarr = Array("ta","td","na","nd","da","dd","pa","pd");
$i = 1;
echo "<select name=\"sortbox\" size=1 OnChange=\"location.href=sort.sortbox.options[selectedIndex].value\">";
while($i != 8){
$r = mysql_fetch_array($CONFIG['default_sort_order']);
if($r['default_sort_order'] == $sortarr[$i]){
$selected = "selected";
}
else{
$selected = "";
}
echo "<option value=\"thumbnails.php?album={AID}&page={PAGE}&sort=.$sortarr[$i].\" ".$selected.">".$sortarr[$i]."</option>";
$i++
}
echo "</selected>";
</form>
It can not possibly work because it contains syntax errors - you're mixing HTML and PHP, which is something you can't do. Haven't looked at your code, but echo '<form name="sort">';
$sortarr = Array("ta","td","na","nd","da","dd","pa","pd");
$i = 1;
echo "<select name=\"sortbox\" size=1 OnChange=\"location.href=sort.sortbox.options[selectedIndex].value\">";
while($i != 8){
$r = mysql_fetch_array($CONFIG['default_sort_order']);
if($r['default_sort_order'] == $sortarr[$i]){
$selected = "selected";
}
else{
$selected = "";
}
echo "<option value=\"thumbnails.php?album={AID}&page={PAGE}&sort=.$sortarr[$i].\" ".$selected.">".$sortarr[$i]."</option>";
$i++
}
echo "</selected>";
echo '</form>';
should at least stop the syntax errors. Please post the entire code, not just snippets.