UBB.Dev
edited by caymuc (I put in Astaran's corrections of the instructions):
Original title was "6.1.1: Count letters of Signature in profile"
Changed that as my instructions were for the Bio, actually. But that all would work for the signature as well, of course. You actually can use the script for both fields with a few changes in the code, I think. - I'll neet to figure out, how.

-------

Where: EditBasic
---
What: A counter of how many letters are still free for use in the bio field.
---
Note: To change the default of how many letters can be uses maximum, change the number at that code in my hack:
var maxlang=250;
---
Status of the hack: Works well in 6.1.1.
---
Status of the instructions: beta - let me know if you understand this here and get it working
---
Example: running on my board; login info, see signature below.
---
Autor: Me, Myself and I


------------
In EDITBASIC.PHP

Replace:

$formmethod = "<form method="post" action="{$config['phpurl']}/changebasic.php">";
By:
// Count-hack next line, name="Profil" added:
$formmethod = "<form name="Profil" method="post" action="{$config['phpurl']}/changebasic.php">";

and

Replace:

$formmethod = "<form method="post" enctype='multipart/form-data' action="{$config['phpurl']}/changebasic.php">";
By:
// Count-hack next line, method="post" added:
$formmethod = "<form name="Profil" method="post" enctype='multipart/form-data' action="{$config['phpurl']}/changebasic.php">";


(Scream, why don't you give all forms a "name" by default? Makes JavaScripts easier to apply. )



In EDITBASIC.TMPL


After:

{$ubbt_lang['PROF_HEAD']} $Username
</td>
</tr>
</table>
</td>
</tr>
</table>

Insert this:

<!-- Count-hack begin -->
<script language="javascript" type="text/javascript">
<!--
var formfeld=" ";
var maxlang=250;
function z()
{
if (window.document.Profil.Bio.value.length>maxlang)
{
window.document.Profil.Bio.value=formfeld;
return;
}
else
{
formfeld=window.document.Profil.Bio.value;
window.document.Profil.anzeigen.value=maxlang-window.document.Profil.Bio.value.length;
}
}
//-->
</script>
<!-- Count-hack end -->

and

replace the full line starting with:

<textarea name="Bio"

by these two lines:
<!-- Count-hack begin -->
<textarea name="Bio" cols="$TextCols" rows="$TextRows" wrap="soft" class="formboxes" onkeyup="javascript:z()">$Bio</textarea>
<input type="text" value="-?-" name="anzeigen" class="formboxes" size="3" />
<!-- Count-hack end -->
Hi Carl,
i took a look at this hack.
Really nice idea, very useful.
But i noticed a few issues during appling this hack.

The changes have to be made in editbasic.php and editbasic.tmpl.
The instructions are written to apply that hack to the bio field an not to the signature field.
You could the variable $config['Sig_length'] to get the maxlength of the signature field from the config file.
Posted By: caymuc Re: 6.1.1: Count letters of Bio in profile - 11/04/2002 9:52 AM
Hi,
yes, i feared that the instructions are not perfect yet.
Also I like your idea to grab the needed variable from the database instead of hard coding it. But I wasn't 100% sure how to do it (and had no time testing it) and what I have here is better than nothing...

Actually I wanted to spread the idea and see whether there is any interest in this feature before I spend any extra time on it. (At the moment I have a so much work at my job that there is no extra time for playing around too much...)
Also there is the hope that Scream would like to include that feature in a standard version, anyway. This Script is a nice service to all board users I think and almost zero effort to include.
© UBB.Developers