UBB.Dev
Posted By: dimopoulos Graemlins Sort Order - 09/29/2002 1:39 AM
Mod Name / Version Graemlins Sort Order 1.0
Description Allows you to sort the order on which the graemlins are shown in the post screens. Also it helps in decoding the graemlin codes.
Working under UBB.threads 6.1
Any pre-requisites None
Author(s) dimopoulos
Credits ubbdev.com who taught me how to do things in php and ubb threads
Demo None.
Files Altered admin/menu.php, ubbt.inc.php, optionally ubbt_instant_ubbcode.tmpl
Database Altered Yes
New Files dochangegrmorder.php, changegrmorder.php
Any other info Please report any problems you might have and I'll try to fix them as soon as possible. Sorry but I have tested this only in version 6.1.


INSTALL
Step 1
Open the file ubbt.inc.php

Step 1.1: Find a line that looks like this (at line 600):
code:

// Convert the smileys
// First grab all smileys out of the database
$query = "
SELECT G_Code,G_Smiley,G_Image
FROM {$config['tbprefix']}Graemlins
ORDER BY G_Smiley
";



And change it to this (we are adding an ORDER BY statement in the query)
code:

// Convert the smileys
// First grab all smileys out of the database
$query = "
SELECT G_Code,G_Smiley,G_Image
FROM {$config['tbprefix']}Graemlins
ORDER BY G_Location DESC
";



Step 1.2: Then find this line (around line 700):
code:

// Convert the smileys
// First grab all smileys out of the database
$query = "
SELECT G_Code,G_Smiley,G_Image
FROM {$config['tbprefix']}Graemlins
ORDER BY G_Smiley
";



And change it to this (we are adding an ORDER BY statement in the query)
code:

// Convert the smileys
// First grab all smileys out of the database
$query = "
SELECT G_Code,G_Smiley,G_Image
FROM {$config['tbprefix']}Graemlins
ORDER BY G_Location DESC
";



Step 1.3: Then find this line (around line 1640):
code:

// --------------------------------------------------
// We need to grab all of the graemlins out of the db
$query = "
SELECT G_Code,G_Smiley,G_Image
FROM {$config['tbprefix']}Graemlins
";



And change it to this (we are adding an ORDER BY statement in the query)
code:

// --------------------------------------------------
// We need to grab all of the graemlins out of the db
$query = "
SELECT G_Code,G_Smiley,G_Image
FROM {$config['tbprefix']}Graemlins
ORDER BY G_Location
";




Step 2
Open up the file admin/menu.php and do the following:

Step 2.1: Find these lines (around line 320):
code:

<br>
<a href="{$config['phpurl']}/admin/removegraemlin.php?Cat=$Cat" target="mainFrame">Remove a graemlin</a>
<br>



And ADD the following AFTER:
code:

<a href="{$config['phpurl']}/admin/changegrmorder.php?Cat=$Cat" target="mainFrame">Sort graemlins order</a>
<br>



Step 3
Upload the files changegrmorder.php and dochangegrmorder.php in your admin folder


Step 4
Run phpMyAdmin and change the Graemlins table (usually w3t_Graemlins) by adding the following field
code:

G_Location INT(11) NULL DEFAULT = 0 (this is zero and not the letter 'O')



the sql script to do so is:
code:

ALTER TABLE `w3t_graemlins` ADD `G_Location` INT( 11 ) DEFAULT '0'



The INT(11) is optional. I think a normal INT will suffice.


OPTIONAL STEP

Step 5
The way the post screens are sructured, the graemlins might push down the 'Submit' button. Hence we can
modify that page to show on two lines the UBB codes, the colors on the next line and below all the
graemlins. This saves space (see attached screenshot)

Step 5.1
Open the ubbt_instant_ubbcode.tmpl and find this (around line 180):
code:

</script>



and CHANGE EVERYTHING below it to this:
code:

<table border="1">
<tr class="tdheader">
<td>
<b>{$ubbt_lang['INST_UBB']}</b>
</td>
</tr>
</table>
<table border="1">
<tr>
<td valign="top" align="left" nowrap="nowrap" class="darktable">
<a href="javascript: x()" onclick="DoPrompt('url');">{$ubbt_lang['J_HYPER']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('email');">{$ubbt_lang['J_EMAIL']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('image');">{$ubbt_lang['J_IMAGE']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('liststart');">{$ubbt_lang['J_LISTSTART']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('listitem');">{$ubbt_lang['J_LISTITEM']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('listend');">{$ubbt_lang['J_LISTEND']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('bold');">{$ubbt_lang['J_BOLD']}</a>
</td>
</tr>
<tr>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('pollstart');">{$ubbt_lang['J_POLLSTART']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('polloption');">{$ubbt_lang['J_POLLOPTION']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('pollstop');">{$ubbt_lang['J_POLLSTOP']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('italics');">{$ubbt_lang['J_ITALICS']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('underline');">{$ubbt_lang['J_UNDERLINE']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('quote');">{$ubbt_lang['J_QUOTE']}</a>
</td>
<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('code');">{$ubbt_lang['J_CODE']}</a>
</td>
</tr>
</table>
<table border="1">
<tr class="tdheader">
<td>
<b>{$ubbt_lang['FONT_COLOR']}</b>
</td>
<td bgcolor="red">
<a href="javascript: x()" onclick="DoColor('red');">    </a>
</td>
<td bgcolor="green">
<a href="javascript: x()" onclick="DoColor('green');">    </a>
</td>
<td bgcolor="blue">
<a href="javascript: x()" onclick="DoColor('blue');">    </a>
</td>
<td bgcolor="white">
<a href="javascript: x()" onclick="DoColor('white');">    </a>
</td>
<td bgcolor="orange">
<a href="javascript: x()" onclick="DoColor('orange');">    </a>
</td>
<td bgcolor="yellow">
<a href="javascript: x()" onclick="DoColor('yellow');">    </a>
</td>
<td bgcolor="black">
<a href="javascript: x()" onclick="DoColor('black');">    </a>
</td>
<td bgcolor="purple">
<a href="javascript: x()" onclick="DoColor('purple');">    </a>
</td>
<td bgcolor="pink">
<a href="javascript: x()" onclick="DoColor('pink');">    </a>
</td>
<td bgcolor="brown">
<a href="javascript: x()" onclick="DoColor('brown');">    </a>
</td>
<td bgcolor="#666666">
<a href="javascript: x()" onclick="DoColor('#666666');">    </a>
</td>
<td>
<a href="javascript: x()" onclick="DoPrompt('color');">?</a>
</td>
</tr>
</table>
<table border="1">
<tr class="tdheader">
<td>
<b>{$ubbt_lang['INST_GRAEMLIN']}</b>
</td>
</tr>
</table>
<table border="1">
<tr>
<tr>
<td valign="top" align="left">
$graemlinlist
</td>
</tr>
</table>



Bare in mind that I have applied the Underline UBB Code Hack on the template. Hence you can see the
code:

<td class="darktable">
<a href="javascript: x()" onclick="DoPrompt('underline');">{$ubbt_lang['J_UNDERLINE']}</a>
</td>


which you might not have in your original template. Please remove if you haven't applied the Underline UBB Code Hack.

Step 5.2
Open the ubbt_inc.php and find this (around line 1830):
code:

$i++;
if ($i==6) {
$i=0;
$graemlinlist .= "<br />";
}



and replace everything below it with (we are commenting out the <BR> every 6 graemlins:
code:

// $i++;
// if ($i==6) {
// $i=0;
// $graemlinlist .= "<br />";
// }



Warm regards

Nikos

Attached File
Posted By: JoshPet Re: Graemlins Sort Order - 09/29/2002 2:00 AM
Cool!

This is much needed.

Thanks!
Posted By: dimopoulos Re: Graemlins Sort Order - 09/29/2002 2:04 AM
No problem Josh. I only hope that this is useful to all and will not cause any major problems since it is my first try for a hack

Warm regards

Nikos
Posted By: JoshPet Re: Graemlins Sort Order - 08/04/2003 2:53 AM
Updated this here:
https://www.ubbdev.com/forum/showflat.php?Board=modifications&Number=90681
© UBB.Developers