View previous topic :: View next topic |
Author |
Message |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Mon Apr 08, 2002 8:50 pm Post subject: B2 Pseudo Smilies Hack |
|
|
Why "pseudo"?
Because in fact it just puts a direct link to your smilies, it doesn't replace a ": )" to
So if you are still interested, here are the instructions:
1. Edit <B2_root>\b2-include\b2quicktags.js and add at the end:
Code: | function smilie(path2smilie) {
smilie2insert='<img alt="" src="' + path2smilie + '" />';
if ((parseInt(navigator.appVersion) >= 4) && (navigator.appName == "Microsoft Internet Explorer"))
theSelection = document.selection.createRange().text; // Get text selection
if (theSelection) {
// Add tags around selection
document.selection.createRange().text = theSelection + smilie2insert + ' ';
document.post.content.focus();
theSelection = '';
return;
}
document.post.content.value += ' ' + smilie2insert + ' ';
document.post.content.focus();
} |
2. Edit <B2_root>\b2-include\b2edit.form.php and replace (around line 92):
Code: | <textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual"><?php echo $content ?></textarea> |
with
Code: | <!--SMILIES HACK BEGIN-->
<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>
<td valign="top" width="90%"><textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual"><?php echo $content ?></textarea></td>
<td valign="top">
<?php
$dir2open="b2-img/smilies"; //dir 2 preview smilies
$dir2include="b2/b2-img/smilies"; //dir 2 include smilies
$nbrcol=4; //columns for the smilies
$handle=opendir($dir2open);
echo "<table>\n";
echo "<tr>\n";
$i=0;
while ($file = readdir($handle)) {
if ($file != "." and $file !=".." and eregi("\.gif$",$file)) {
if ($i==$nbrcol) {
echo "</tr><tr>\n";
$i=0;
}
echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$siteurl/$dir2include/$file')\" style=\"cursor:hand\"></td>\n";
$i++;
}
}
echo "</tr>\n";
echo "</table>\n";
closedir($handle);
?>
</td>
</tr></table>
<!--SMILIES HACK END--> |
Don't forget to make $dir2open, $dir2include and $nbrcol suit your needs.
They represent:
$dir2open > you'll most likely not change it, it's the path from b2edit.php to the path where are the smilies
$dir2include > the path from your b2.php (or whatever you call it) to the path where are the smilies
$nbrcol > number of columns of the table including the smilies
Also, my code searches the path for .gif files only, but replacing "and eregi("\.gif$",$file)" in the if condition with "and (eregi("\.gif$",$file) or eregi("\.jpg$",$file))" will allow you to see also the jpeg files (for example).
The only "bug" of this hack is that (at least for me), as $dir2open and $dir2include are different, the images don't show up in the preview in the admin area. Apart from this, it works!
And my news page: http://www.newcomics.fr.st
UPDATE: works with 0.6pre2.
Benjy.
Last edited by Benjy on Tue May 14, 2002 7:23 pm; edited 3 times in total |
|
Back to top |
|
 |
dodo
Joined: 25 Jan 2002 Posts: 35
|
Posted: Thu Apr 11, 2002 6:56 am Post subject: awesome |
|
|
awesome job there.. just a small note
to keep b2 xml-compliant, i edited your javascript code a little bit
just updated the code line to
Code: |
smilie2insert='<img alt="" src="' + path2smilie + '" />';
|
thanks for the hack!! _________________ http://pure-essence.net
b2 rocks |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Thu Apr 11, 2002 9:42 am Post subject: |
|
|
Well, yes, sorry I didn't think about XML :p
Btw thx, I update my post right now!
Benjy. |
|
Back to top |
|
 |
identityless
Joined: 25 Jan 2002 Posts: 22
|
Posted: Thu Apr 11, 2002 7:30 pm Post subject: |
|
|
this is great! |
|
Back to top |
|
 |
nessahead
Joined: 12 Mar 2002 Posts: 312 Location: Los Angeles, CA
|
Posted: Thu Apr 11, 2002 11:35 pm Post subject: |
|
|
Just installed this puppy and it went smoothly =) Thanks! |
|
Back to top |
|
 |
lornaly
Joined: 20 Apr 2002 Posts: 2
|
Posted: Wed Apr 24, 2002 1:06 pm Post subject: Cool hack |
|
|
I add this hack today the only thing is that i have to replace "b2/b2-img/smilies" to ./b2-img/smilies manually in the text area. btw i can see the smilies in my admin area good work |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Wed Apr 24, 2002 10:16 pm Post subject: |
|
|
Just change your Code: | $dir2include="./b2/b2-img/smilies"; | to Code: | $dir2include="./b2-img/smilies"; | The variable is meant for this
Benjy. |
|
Back to top |
|
 |
lornaly
Joined: 20 Apr 2002 Posts: 2
|
Posted: Thu Apr 25, 2002 11:11 am Post subject: thanks |
|
|
I did that yesterday, thanks! |
|
Back to top |
|
 |
nessahead
Joined: 12 Mar 2002 Posts: 312 Location: Los Angeles, CA
|
Posted: Fri May 03, 2002 10:04 pm Post subject: |
|
|
Ok, I totally didn't realize that your hack gets its list of smilies from the files that are in the smilied directory! I can replace them and add or subtract as I want and there's no code to modify! Duh me =P
Anyhow, you rock! An even better hack than I thought at first =) |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Sat May 04, 2002 11:17 pm Post subject: |
|
|
Thx again
Benjy. |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Tue May 14, 2002 7:20 pm Post subject: |
|
|
UPDATE!
Changed Code: | $dir2open="./b2-img/smilies"; //dir 2 preview smilies
$dir2include="./b2/b2-img/smilies"; //dir 2 include smilies | to Code: | $dir2open="b2-img/smilies"; //dir 2 preview smilies
$dir2include="b2/b2-img/smilies"; //dir 2 include smilies | (removed the "./")
and Code: | echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$dir2include/$file')\" style=\"cursor:hand\"></td>\n"; | to Code: | echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$siteurl/$dir2include/$file')\" style=\"cursor:hand\"></td>\n"; | (added $siteurl/ so that smilies display well, even in the preview ) |
|
Back to top |
|
 |
maka
Joined: 09 May 2002 Posts: 4 Location: Oklahoma
|
Posted: Wed May 22, 2002 4:46 pm Post subject: this is cool, but... |
|
|
i'm using this and love it, but i've got so many smilies that i decided to move them to below the textedit area...still it's a huge bunch of smilies and they take a little while to load...i'm wondering if it would be possible to just have a pop-up window with all the smilies in it that would still accomplish this? (send the <img> tag code back to the b2edit or else copy it to the clipboard maybe?)
here's the code for the alternate placement of the smilies
Code: |
<!--SMILIES HACK BEGIN-->
<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>
<td valign="top" width="90%"><textarea rows="9" cols="40" style="width:100%" name="content" tabindex="4" wrap="virtual"><?php echo $content ?></textarea></td>
</tr><tr><td valign="top">
<?php
$dir2open="./b2-img/smilies"; //dir 2 preview smilies
$dir2include="./b2-img/smilies"; //dir 2 include smilies
$nbrcol=24; //columns for the smilies
$handle=opendir($dir2open);
echo "<table>\n";
echo "<tr>\n";
$i=0;
while ($file = readdir($handle)) {
if ($file != "." and $file !=".." and eregi("\.gif$",$file)) {
if ($i==$nbrcol) {
echo "</tr><tr>\n";
$i=0;
}
echo "<td><img src=\"$dir2open/$file\" onClick=\"smilie('$dir2include/$file')\" style=\"cursor:hand\"></td>\n";
$i++;
}
}
echo "</tr>\n";
echo "</table>\n";
closedir($handle);
?>
</td>
</tr></table>
<!--SMILIES HACK END-->
|
_________________ Love & Light....
Maka, single stay-at-home bad-ass crunchy mama
to Daystar (fsbc 6/23/91),
to Griffin (uhb 7/11/99),
and to many other babies never held in arms! |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
Posted: Wed May 22, 2002 10:13 pm Post subject: |
|
|
Of course it is possible!
Problem is I don't have much time right now, but I'll do it ASAP
Benjy. |
|
Back to top |
|
 |
maka
Joined: 09 May 2002 Posts: 4 Location: Oklahoma
|
Posted: Thu May 23, 2002 2:23 am Post subject: thanks! |
|
|
thanks benjy!! i'll be watching for it! _________________ Love & Light....
Maka, single stay-at-home bad-ass crunchy mama
to Daystar (fsbc 6/23/91),
to Griffin (uhb 7/11/99),
and to many other babies never held in arms! |
|
Back to top |
|
 |
Benjy
Joined: 25 Jan 2002 Posts: 108 Location: Paris, France
|
|
Back to top |
|
 |
|