Recent Topics

1 Feb 26, 2005 03:16    

version is 0.9.0.11, hack is distilled from [url=http://forums.b2evolution.net/viewtopic.php?t=2700]good old t=2700[/url], many thanks to ????? and stk for all the work back when comments were just text.

4 files, 5 if you're feeling a bit fiesty.

Start with b2evocore/_class_comment.php. Find and add:

	function content( $format = 'htmlbody' ) 
	{
		$comment = $this->content;
		$comment = str_replace('<trackback />', '', $comment);
		$comment = str_replace('<pingback />', '', $comment);
		$comment = format_to_output( $comment, $format );
		// Start emoticon (aka smilie) in comments hack
		global $Renderer;
		$renderers = explode( ".","b2evSmil" );
		$post_renderers = $Renderer->validate_list( $renderers );
		$comment = $Renderer->render( $comment, $post_renderers, $format );
		// End emoticon (aka smilie) in comments hack
		echo $comment;
	}

Now edit b2evocore/_class_toolbars.php. Find and add:

	function display()
	{
		$this->init();	// Init if not done yet.

		$this->index_Plugins['b2evQTag']->display();
		$this->index_Plugins['b2evSmil']->display();
	}	

	// Start emoticon (aka smilie) in comments hack
	function comment_display()
	{
		$this->init(); // Init if not done yet.
		$this->index_Plugins['b2evSmil']->display();
	}
	// End emoticon (aka smilie) in comments hack

Now crack open a frosty cold plugins/toolbars/_smilies.toolbar.php. Find and add:

		function grin(tag)
		{
			var myField;
			if (document.getElementById('content') && document.getElementById('content').type == 'textarea') {
				myField = document.getElementById('content');
			}
			// Start emoticon (aka smilie) in comments hack
			else if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {
				myField = document.getElementById('comment');
			}
			// End emoticon (aka smilie) in comments hack
			else {
				return false;
			}

NOTE: If you're into xhtml validation you will want to change line 84 from
									'" class="top" onclick="grin(\''. str_replace("'","\'",$smiley). '\');"/> ';

to

									'" class="top" onclick="grin(\''. str_replace("'","\'",$smiley). '\');" /> ';

or

									'" class="top" onclick="grin(\''. str_replace("'","\'",$smiley). '\');" /> '."\n";

The first puts a space before the self-closing part of the smilie img tag. The second makes your source code look pretty.

Fourth file is EITHER skins/_feedback.php OR skins/skinname/_feedback.php. If your skins/skinname/_feedback.php ends with

	require get_path('skins').'/_feedback.php';
?>

then you make the hack in skins/_feedback.php.

In the correct _feedback.php find and add:

				form_text( 'url', $comment_author_url, 40, T_('Site/Url'), T_('Your URL will be displayed.'), 100, 'bComment' );
			} 

			// Start emoticon (aka smilie) in comments hack ?>
			<fieldset>
				<div class="label"><?php echo T_('Smilies') ?>:</div>
				<div class="info">
					<?php $Toolbars->comment_display(); ?>
					</div>
			</fieldset>
			<?php
			form_textarea( 'comment', '', 12, T_('Comment text'), T_('Allowed XHTML tags').': '.htmlspecialchars(str_replace( '><',', ', $comment_allowed_tags)).'<br />'.T_('URLs, email, AIM and ICQs will be converted automatically.'), 40, 'bComment' );
			?> 
			<?php // End emoticon (aka smilie) in comments hack ?>
					
			<fieldset>
				<div class="label"><?php echo T_('Options') ?>:


Note that the form_textarea line is inside the start and end of the hack. Whatever. No biggie.

Upload these four files and you will have clickable smilies for commenters.

You might want to make a change to your skin's css depending on if your smilies look like they are all bunched together. What happens is the typical skin has less screen width available for the comment textarea than you have in the back office for posting. This, and the number of smilies you've got, makes the second row of smilies sitting directly under the first row. No biggie - just add a groovy new bit to your skin's style sheet.

.info .edit_toolbar img {
	margin: 2px; /* adjust as you see fit */
}


Upload that and the crowding issue will be resolved.

2 Feb 26, 2005 12:43

well thank you very much for explaining all this. Unfortunately it didn't work completely: The letters S-m-i-l-i-e-s appear above the comment area, but next to it (where the smilies should be) there is nothing, no smilies. And i followed the steps carefully. What to do?

3 Feb 26, 2005 14:23

Got link? What browser are you using? I just looked at my test installation in IE and it was really funny watching the emoticons appear to pop in from the right edge then sort of move to where they belong. Got other mods in your skin? Can you try it with a clean 'custom' skin?

4 Feb 26, 2005 15:44

okay sorry got it showing now: www.kannibaal.be
i forgot that in _smilies_toolbar.php var $display = true; should be set to TRUE, it was set to false.

But is it possible that the smilies are not clickable?

5 Feb 26, 2005 16:45

Okay that's progress. I see you are running version 0.9.0.10 and I don't know what changes between it and v11 might affect this. Anyway the original thread had some different stuff that I left out of this post because, well, because it worked this way in v11. Here's what I *THINK* might help:

In _smilies.toolbar.php:

 function grin(tag)
{
var myField;
if (b2evoCanvas&& b2evoCanvas.type == 'textarea') {
myField = b2evoCanvas;
}
else {
if (document.getElementById('content') && document.getElementById('content').type == 'textarea') {
myField = document.getElementById('content');
}
else{

return false;
}
}

In your _feedback.php:

// begin emoticons in comments hack
<fieldset>
<div class="label"><?php echo T_('Smilies') ?>:</div>
<div class="info">
<?php $Toolbars->comment_display(); ?>
</div>
</fieldset>
// end emoticons in comments hack

form_textarea( 'comment', '', 12, T_('Comment text'), T_('Allowed XHTML tags').': '.htmlspecialchars(str_replace( '><',', ', $comment_allowed_tags)).'<br />'.T_('URLs, email, AIM and ICQs will be converted automatically.'), 40, 'bComment' );

// begin emoticons in comments hack ?>
<script type="text/javascript" language="JavaScript">
<!--
var b2evoCanvas = document.getElementById('comment');
//-->
</script>
<?php // end emoticons in comments hack ?> 

I can't be sure if this will help or not. It was part of the original method to make this whole thing work, but as it turns out it wasn't needed for v11.

EDIT: These would be changes instead of the changes identified in the first post in this thread. Keep an eye on your classes and form name and stuff like that to make sure that you do not change from what you have to what this hack thinks you have!

6 Feb 26, 2005 17:09

maybe i better update to v 0.9.0.11

7 Feb 26, 2005 21:41

First of all, thank you EdB! I'm a new user of b2evolution but I think I found the Sacred Graal in blog engine! :)
Now, let's come to my problem: smilies. I have no problem writing a message from scratch (the toolbar is working fine), but in comments the icons appear but I can't click on... I rechecked two times this thread and everything seems ok in my files...
My blog: http://skyone.altervista.org/skyblogone/
I have the problem with Firefox and IE6.

TIA

8 Feb 26, 2005 23:19

I'm going to re-install my v11 test installation and follow my own instructions to see what's going on here. It's weird because once we got it working it was no problem. Now a v10 and v11 can't get it to work, and I can't for the life of me understand why not.

Can you switch to clean urls? Just a curiosity is all. I also noticed some comments with emoticons in them in your blog. Do you know if the commenter typed the correct text string or if they happened to be lucky and clicking worked? In fact can you type a smilie code in a comment on your blog to see if the rendering is happening?

I'm also going to log out of the installation I have it working on just to see if for some odd reason that matters.

9 Feb 26, 2005 23:31

I'm sorry, but I don't know what a "clean url" is...
The rendering is ok: the emoticons in the comments appeared after I followed your suggestions in this thread.

10 Feb 26, 2005 23:58

clean urls means going from ?foo=bar&blah=bleh&this=that to /year/month/day/title, but it really means going to your back office on the settings tab and checking the "Use extra-path info" box. No biggie - I DOUBT it's part of the issue here.

So far we know that your smilies show up in comments, and if you type in the code they render correctly. The thing that's not working is making them be clickable.

I just now followed my own instructions and all went as one would hope. Bummer, as I was hoping to catch a flaw in my initial post. Let me poke around your source code and compare it to mine to see if I can figure something out. There is a distinct possibility that I'll just pass out soon, but that's just the way it is with me on non-flying days.

BRB (eventually...)

11 Feb 27, 2005 00:23

EdB wrote:

Okay that's progress. I see you are running version 0.9.0.10 and I don't know what changes between it and v11 might affect this. Anyway the original thread had some different stuff that I left out of this post because, well, because it worked this way in v11. Here's what I *THINK* might help:

In _smilies.toolbar.php:

 function grin(tag)
{
var myField;
if (b2evoCanvas&& b2evoCanvas.type == 'textarea') {
myField = b2evoCanvas;
}
else {
if (document.getElementById('content') && document.getElementById('content').type == 'textarea') {
myField = document.getElementById('content');
}
else{

return false;
}
}

In your _feedback.php:

// begin emoticons in comments hack
<fieldset>
<div class="label"><?php echo T_('Smilies') ?>:</div>
<div class="info">
<?php $Toolbars->comment_display(); ?>
</div>
</fieldset>
// end emoticons in comments hack

form_textarea( 'comment', '', 12, T_('Comment text'), T_('Allowed XHTML tags').': '.htmlspecialchars(str_replace( '><',', ', $comment_allowed_tags)).'<br />'.T_('URLs, email, AIM and ICQs will be converted automatically.'), 40, 'bComment' );

// begin emoticons in comments hack ?>
<script type="text/javascript" language="JavaScript">
<!--
var b2evoCanvas = document.getElementById('comment');
//-->
</script>
<?php // end emoticons in comments hack ?> 

I can't be sure if this will help or not. It was part of the original method to make this whole thing work, but as it turns out it wasn't needed for v11.

EDIT: These would be changes instead of the changes identified in the first post in this thread. Keep an eye on your classes and form name and stuff like that to make sure that you do not change from what you have to what this hack thinks you have!

So this makes the smilies clickable??

12 Feb 27, 2005 00:26

Okay! This might help bashiro and Sky One. I took a deep look at the source code from Sky One's page and found a significant difference (which, by the way, spelling such big words is a sifnidgnact accomplishment for me right now).

I can not say *exactly* what went wrong, but there is a noticable difference in the source code where the smilies are. They are displayed properly, but the javascript function "grin(tag)" has a critical difference. That is covered in the plugins/toolbars/_smilies.toolbar.php portion of the hack. Specifically, Sky One's source looked like this:

if (document.getElementById('content') && document.getElementById('content').type == 'textarea') {
myField = document.getElementById('content');
}
else {
return false;
}


My version looks like this:

if (document.getElementById('content') && document.getElementById('content').type == 'textarea') {
myField = document.getElementById('content');
}
// Start emoticon (aka smilie) in comments hack
else if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {
myField = document.getElementById('comment');
}
// End emoticon (aka smilie) in comments hack
else {
return false;
}

It effectively looks like that file is unmodified. I would suggest going there to make sure that you matched the example provided above. The key to that particular change is to go from "if (these conditions then this stuff) else return" to "if (these conditions then this stuff) else if (these other conditions then this other stuff) else return". The second if (or the else if, if you prefer) is looking to see if you are doing the smilies on a comment form.

Anyway I either need fresh ice or a nap.

14 Feb 27, 2005 12:32

okay got it working now. Thank you very much!!!

15 Aug 29, 2005 05:01

Hi, just a quick thank for this hack that is really great, but I have one issue with my skin (it's Reflection : http://skins.b2evolution.net/a.php?skin=reflection by Danny Ferguson) I made some changes from the original one, but the original one doesn't work properly.
It's coming from my css: in firefox, the look of the comment field looks pretty ugly ! (while it's ok in IE)
Do you think you have any hint on what may cause this ?
http://piechdibi.net

Thanks a lot
Paul

16 Aug 29, 2005 05:17

Hi piechdibi. Could you be a bit more specific on what you mean by "the look of the comment field"? To me, in Firefox 1.0.6, I'm seeing an okay comments field, but I see a problem with 2 of your smilies overlapping the "Texte du commentaire:" (which I reckon means "type something here"). If that's the problem you are concerned with I'll get on it. It's not cool, and it's not supposed to happen that way. It should give a new line after the smilies so people can see the next field is for leaving a comment.

Not this minute though - I got a little project going on as well as a little buzz. It's hard for me to change project gears when the floor is so close... :D

17 Aug 29, 2005 10:59

since a good view is better than a bad explanation, here's what I got :
In firefox:
http://www.piechdibi.net/blog/firefox.jpg

and under IE:
http://www.piechdibi.net/blog/ie.jpg

It's actually the first time I'm actually happy with IE (have you seen the nasty bullets IE does with my categories? arg! lol)

anyway, if you're currently working on something else, don't worry it's not that urgent!
Cheers
piechdibi.

PS: That might help: I'm using b2 0.9.0.11, firefox 1.0.6 with a resolution of 1280x800

My guess is taht the css of the skin is not really correct, since apparently there are no styles defined for the comments...

18 Aug 29, 2005 12:56

It's caused by this section of your css :-

.info {
  height: 3em;
  font-size: 0.8em;
  text-transform: lowercase;
  line-height: 2.6em;
  float: right;
}

¥

19 Aug 29, 2005 13:18

I can't believe it was that easy! thanks a lot for your quick answers !!!

21 Aug 29, 2005 15:58

Thanks ¥åßßå! It's really hard for me to re-think an old hack, but I sort of feel obligated so I always try. It was nice to see that you resolved piechdibi's issue.

22 Aug 29, 2005 19:55

Being an old fart I can risk repeating myself "no problem ;)" ;)

¥

23 Aug 30, 2005 03:42

he he I'd just like to say thank you again, it works perfectly now!

Ok, so this is off topic, but I realised that the css files in the skin repository were not really harmonized, so that everytime you download a new skin, you have to discover exactly what style stands for in each css, and I feel like it's kind of a waste of time... Is this clear ?

So I thought that maybe there could be a guide for that, a support indicating that all skins should have styled named like "header" and "subheader" for the banner of the site or "bposts"...
So this way, no need to seek in the each skin _main.php to understand every style! :)

But I realise it may be too complicated to organize, since a lot of skins already exist :roll:

24 Sep 06, 2005 15:54

Do you know how I can limit the number of smileys available in comments ?
I mean I want to display in backoffice all smileys, but for comments, only the first 10.

25 Sep 06, 2005 18:56

I don't know about using a specific subset of the emoticon set for posts, but I was able to make up a low-level hack that gives me a secondary emoticon set for comments. Looks like 3 files need to be created and a 4th modified. Also the _feedback.php file will need to be tweaked as described above. Actually any file modified for the original hack that isn't re-hacked here will probably need to be done. Basically I copied the original hack then tweaked it to use my new smilie set.

In the plugins folder copy _smilies.conf.php as _C_smilies.conf.php and make 2 changes:

# the directory where your smilies are (no trailing slash)
$this->C_smilies_path = $img_url.'/smilies';


Then include the smilies you want for comments:

# here's the conversion table, you can modify it if you know what you're doing
# smilies will be displayed in their order of appearance
$this->smilies = array(


Technically it would be a matter of excluding the ones you don't want, but I also changed the string that becomes the smilie. In my back office I use ":emo1523:" and in comments I use ":C01:" (without quotation marks).

Next in plugins/renderers copy _smilies.renderer.php as _C_smilies.renderer.php and make quite a few changes. To save a bit of space here I'll leave out the before and show you the after.

class C_smilies_Rendererplugin extends RendererPlugin
{
	var $code = 'b2C_Smil';
	var $name = 'C_Smilie';


Then

	var $C_smilies;

and

	var $C_smilies_path;


The Constructor:

	function C_smilies_Rendererplugin()
	{
		$this->short_desc = T_('Convert text smilies to icons');
		$this->long_desc = T_('No description available');
		require dirname(__FILE__). '/../_C_smilies.conf.php';
	}


In function render() a couple of details:

			uksort($tmpsmilies, 'C_smiliescmp');

and

				$this->replace[] = '<img src="'.$this->C_smilies_path.'/'.$img.'" alt="'.$smiley_masked.'" class="middle" />';

Now copy plugins/toolbars/_smilies.toolbar.php as _C_smilies.toolbar.php and make a few edits to your new file:

class C_smilies_Toolbarplugin extends ToolbarPlugin

and

	var $code = 'b2C_Smil';
	var $name = 'C_Smilie';
	var $priority = 40;

and

	var $C_smilies;

and

	var $C_smilies_path;


Same file, a couple more changes:

	function C_smilies_Toolbarplugin()
	{
		$this->short_desc = T_('One click smilies inserting');
		$this->long_desc = T_('No description available');

		require dirname(__FILE__). '/../_C_smilies.conf.php';
	}

and

				$grins .= '<img src="'. $this->C_smilies_path. '/'. $grin. '" alt="'. $smiley.
									'" class="top" onclick="grin(\''. str_replace("'","\'",$smiley). '\');" /> '."\n";
			}

and a bit from the original hack:

			if (document.getElementById('content') && document.getElementById('content').type == 'textarea') {
				myField = document.getElementById('content');
			}
			// Start emoticon (aka smilie) in comments hack
			else if (document.getElementById('comment') && document.getElementById('comment').type == 'textarea') {
				myField = document.getElementById('comment');
			}
			// End emoticon (aka smilie) in comments hack
			else {
				return false;
			}

and finally:

// Register the plugin:
$this->register( new C_smilies_Toolbarplugin() );

One more file tweak. In b2evocore/_class_toolbars.php make a minor change to the original hack:

	function display()
	{
		$this->init();	// Init if not done yet.
		$this->index_Plugins['b2evQTag']->display();
		$this->index_Plugins['b2evSmil']->display();
		$this->index_Plugins['evo_ccom']->display();
	}	
	
	// Start emoticon (aka smilie) in comments hack
	function comment_display()
	{
		$this->init(); // Init if not done yet.
		$this->index_Plugins['b2C_Smil']->display();
	}
	// End emoticon (aka smilie) in comments hack

The Sucky Part:In your back office on your write tab you get a checkbox for the comments emoticons. I never tested what happens if a blogger un-checks the box, and I think I'd prefer to not even see the new "C_smilies" checkbox at all. Maybe you can turn off smilies on a post-by-post basis with this, but it didn't matter to me since I'm my only blogger. If anyone uses this hack-on-hack and tests that last little piece how about letting people know what happens? Also if anyone sees a way to not have a checkbox for C_smilies in the back office that'd be cool too.

27 Nov 04, 2005 08:48

Got it working.Just had to change the _smilies.toolbar

28 Oct 31, 2006 12:17

Can you help me ?

What do i need to change. I want also emoticons in the comments.
hope you can help me.

with regards,
Ruud

29 Nov 06, 2006 12:22

is this plugin workin with ver. 1.82 ? cuase 1.82 dont have b2evocore/

30 Nov 06, 2006 15:28

No. I did not put a dime of energy into this hack after it was created. Sorry :(

31 Nov 24, 2006 16:36

Hi,
When I click to post the message containing smilies appear many error such as

Warning: Cannot modify header information - headers already sent by (output started at /home/mariarte/public_html/spanienblog/b2evocore/_class_toolbars.php:104) in /home/mariarte/public_html/spanienblog/htsrv/comment_post.php on line 198

Appreciate any advise! Thanks!

Maria 8|

33 Nov 24, 2006 20:17

Thank you, all fixed! :lol:


Form is loading...