comments.tpl Javascript

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

comments.tpl Javascript

Post by yellowled »

The default comments.tpl contains this onclick handler:

Code: Select all

<a class="comment_reply" href="#serendipity_CommentForm" id="serendipity_reply_{$comment.id}" onclick="document.getElementById('serendipity_replyTo').value='{$comment.id}'; {$comment_onchange}">{$CONST.REPLY}</a>
I'm trying to understand what this does -- it first sets the value of #serendipity_replyTo to the id of the corresponding link. But what does {$comment_onchange} do?

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: comments.tpl Javascript

Post by garvinhicking »

Hi!

comment_onchange is a plugin event handler so that other plugins can execute stuff there, like the livecommentpreview plugin.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: comments.tpl Javascript

Post by yellowled »

garvinhicking wrote:comment_onchange is a plugin event handler so that other plugins can execute stuff there, like the livecommentpreview plugin.
Hm. I'm trying to build a template using as little inline JS and CSS as possible by putting them in external JS/CSS files as far as possible. I think I have figured out how to do the first part, but I have no idea how to handle the {$comment_onchange}, especially since I don't have access to smarty variables in external JS files. So it's probably pointless. Too bad.

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: comments.tpl Javascript

Post by garvinhicking »

Hi!

You'd always need to place it inside your comment-tpl to stay compatible to those plugins.

What you could do is

Code: Select all

{if $comment_onchange != ''}
<a ... onclick="{$comment_onchange}">
{else}
<a>
{/if}
So if your jquery took care about injecting the onclick to getElementById, you only need to have a onclick inline handler, if users are using a plugin that would require it.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: comments.tpl Javascript

Post by yellowled »

Code: Select all

<a class="comment_reply" href="#serendipity_CommentForm" id="serendipity_reply_{$comment.id}"{if $comment_onchange != ''} onclick="{$comment_onchange}"{/if}>{$CONST.REPLY}</a>
should work too, right? If so: Thanks a lot :)

YL
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: comments.tpl Javascript

Post by garvinhicking »

Yip
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply