Drop Down Menu for Sorting Order Mod Drop Down Menu for Sorting Order Mod
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Drop Down Menu for Sorting Order Mod

Started by jeepguy_1980, March 23, 2009, 04:49:00 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jeepguy_1980

I wanted to make it so that the menu would automatically display the sorting order being used. However, that was a bit over my head. So here is my mod as it exists now.

This mod will replace the sort order menu with a drop down menu.  I designed it for the themes where the sort order menu runs past the table detracting from the otherwise nice theme.

i.e. changes from Attachment1 to Attachment2 and Attachment 3

To make this change, open theme.php

Find the following function:
$template_thumb_view_title_row = <<<EOT

Replace the entire function with the following:

// 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}&amp;page={PAGE}&amp;sort=ta">{TITLE} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=td">{TITLE} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=na">{NAME} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=nd">{NAME} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=da">{DATE} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=dd">{DATE} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pa">{POSITION} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pd">{POSITION} -</option>
</select>
</form>
                                </td>
                        </tr>
                        </table>

EOT;
}  //{THEMES}


Depending on your theme, you may need to adjust your theme's style.css ".sortorder_cell" padding to make it line up better.

Heroe

Hi jeepguy_1980 ,
Thank for the nice mod, but for me the mod seems dont work on my theme ;( the box appear but doesn't change the sort order.

I copy and paste the function from yr post in my theme:

// 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}&amp;page={PAGE}&amp;sort=ta">{TITLE} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=td">{TITLE} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=na">{NAME} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=nd">{NAME} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=da">{DATE} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=dd">{DATE} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pa">{POSITION} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pd">{POSITION} -</option>
</select>
</form>
                                </td>
                        </tr>
                        </table>

EOT;
}  //{THEMES}


My theme.php is attached if u can have a look.

Here is the gallery link:

CPG Version :1.4.24
www.abroadbg.com
username: test
password:123654

Joachim Müller

#2
Quote from: jeepguy_1980 on March 23, 2009, 04:49:00 AMFind the following function:
$template_thumb_view_title_row = <<<EOT
That's not a function, but merely a variable getting populated.

Quote from: jeepguy_1980 on March 23, 2009, 04:49:00 AMReplace the entire function with the following:

// 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}&amp;page={PAGE}&amp;sort=ta">{TITLE} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=td">{TITLE} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=na">{NAME} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=nd">{NAME} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=da">{DATE} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=dd">{DATE} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pa">{POSITION} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pd">{POSITION} -</option>
</select>
</form>
                               </td>
                       </tr>
                       </table>

EOT;
}  //{THEMES}
No, don't do that - that's silly. Actually, the instructions need to be as following:

Edit themes/yourtheme/theme.php with a plain text editor. Find $template_thumb_view_title_row = <<<EOTand edit as suggested below. If that section doesn't exist in your custom theme, copy // HTML template for title row of the thumbnail view (album title + sort options)
$template_thumb_view_title_row = <<<EOT

                       <table width="100%" cellpadding="0" 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">
                                       <table cellpadding="0" cellspacing="0">
                                       <tr>
                                               <td class="sortorder_options">{TITLE}</td>
                                               <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=ta" title="{SORT_TA}">&nbsp;+&nbsp;</a></span></td>
                                               <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=td" title="{SORT_TD}">&nbsp;-&nbsp;</a></span></td>
                                       </tr>
                                       <tr>
                                               <td class="sortorder_options">{NAME}</td>
                                               <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=na" title="{SORT_NA}">&nbsp;+&nbsp;</a></span></td>
                                               <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=nd" title="{SORT_ND}">&nbsp;-&nbsp;</a></span></td>
                                       </tr>
                                       <tr>
                                               <td class="sortorder_options">{DATE}</td>
                                               <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=da" title="{SORT_DA}">&nbsp;+&nbsp;</a></span></td>
                                               <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=dd" title="{SORT_DD}">&nbsp;-&nbsp;</a></span></td>
                                       </tr>
                                       <tr>
                                               <td class="sortorder_options">{POSITION}</td>
                                               <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pa" title="{SORT_PA}">&nbsp;+&nbsp;</a></span></td>
                                               <td class="sortorder_options"><span class="statlink"><a href="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pd" title="{SORT_PD}">&nbsp;-&nbsp;</a></span></td>
                                       </tr>
                                       </table>
                               </td>
                       </tr>
                       </table>

EOT;
from themes/sample/theme.php into a new line before?>of the file themes/yourtheme/theme.php

Then replace your definition of $template_thumb_view_title_row  with the following code:$template_thumb_view_title_row = <<<EOT

                       <form name="sort" action="{$_SERVER['REQUEST_URI']}" method="get">
<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">
<select name="sortbox" OnChange="location.href=sort.sortbox.options[selectedIndex].value">
<option>Sorting Order</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=ta">{TITLE} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=td">{TITLE} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=na">{NAME} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=nd">{NAME} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=da">{DATE} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=dd">{DATE} -</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pa">{POSITION} +</option>
<option value="thumbnails.php?album={AID}&amp;page={PAGE}&amp;sort=pd">{POSITION} -</option>
</select>
</td>
</tr>
</table>
</form>

EOT;


@jeepguy_1980: never copy stuff from include/themes.inc.php! Always copy stuff from themes/sample/theme.php instead!

Heroe

Joachim Müller

Don't understand what im doing wrong, nothing don't change after yr instructions. I did all u wrote in yr last post  ???

I attached again my theme.php


Joachim Müller

I have no idea what you're talking about: your site looks exactly as advertized for me (see attached screenshot). Make sure that you're not looking at a cached copy. Force-refresh your browser with [Ctrl]+[F5].

Heroe

Quote from: Joachim Müller on December 16, 2009, 09:48:51 AM
I have no idea what you're talking about: your site looks exactly as advertized for me (see attached screenshot). Make sure that you're not looking at a cached copy. Force-refresh your browser with [Ctrl]+[F5].

I mean users and me can't change anymore the sort order from the
/thumbnails.php?album=xxx  list.

your site looks exactly as advertized for me

What u mean GauGau, i don't understand u ???