Message after posting a comment

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
ruijt
Regular
Posts: 16
Joined: Sun Mar 27, 2005 3:32 pm

Message after posting a comment

Post by ruijt »

Hi,

Can anyone please help me. I'm trying to get rid of the message you get right after posting a comment (pop-up mode). What I want is that after you press the submit button, the pop-up windows shows the comments again instead of the message "your message has been submitted, click here to get back to the comments".

I can't find how to do this.

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

Re: Message after posting a comment

Post by garvinhicking »

Edit your commentform.tpl template.

One possible suggestion is this:

Code: Select all

{if $is_xhtml}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{else}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
{/if}

<html>
<head>
    <title>{$head_title|@default:$blogTitle} {if $head_subtitle} - {$head_subtitle}{/if}</title>
    <meta http-equiv="Content-Type" content="text/html; charset={$head_charset}" />
    <meta name="Powered-By" content="Serendipity v.{$head_version}" />
    <link rel="stylesheet" type="text/css" href="{$serendipityHTTPPath}serendipity.css.php" />
    <link rel="alternate"  type="application/rss+xml" title="{$blogTitle} RSS feed" href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/index.rss2" />
    <link rel="alternate"  type="application/x.atom+xml"  title="{$blogTitle} Atom feed"  href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/atom.xml" />
</head>

<body class="s9y_wrap" id="serendipity_comment_page">

{if $is_comment_added}

    {$CONST.COMMENT_ADDED}{$comment_string.0}<a href="{$comment_url}">{$comment_string.1}</a>{$comment_string.2}<a href="#" onclick="self.close()">{$comment_string.3}</a>{$comment_string.4}

{elseif $is_comment_notadded}

    {$CONST.COMMENT_NOT_ADDED}{$comment_string.0}<a href="{$comment_url}">{$comment_string.1}</a>{$comment_string.2}<a href="#" onclick="self.close()">{$comment_string.3}</a>{$comment_string.4}

{elseif $is_comment_empty}

    {$CONST.EMPTY_COMMENT}{$comment_string.0}<a href="#" onclick="history.go(-1)">{$comment_string.1}</a>

{/if}
{if $is_showtrackbacks}

    <div class="serendipity_commentsTitle">{$CONST.TRACKBACKS}</div><br />
    <dl>
        <dt><b>{$CONST.TRACKBACK_SPECIFIC}:</b><br /></dt>
        <dd><a rel="nofollow" href="{$comment_url}">{$comment_url}</a><br /></dd>

        <dt><b>{$CONST.DIRECT_LINK}:</b><br /></dt>
        <dd><a href="{$comment_entryurl}">{$comment_entryurl}</a></dd>
    </dl>

    {serendipity_printTrackbacks entry=$entry_id}

{elseif $is_showcomments}

    <div class="serendipity_commentsTitle">{$CONST.COMMENTS}</div>

    {serendipity_printComments entry=$entry_id}
    {if $is_comment_allowed}
        <div class="serendipity_commentsTitle">{$CONST.ADD_COMMENT}</div>
        {$COMMENTFORM}
    {else}
        <div class="serendipity_center serendipity_msg_important">{$CONST.COMMENTS_CLOSED}</div>
    {/if}

{/if}

</body>
</html>

About in the middle of the code I broke the if/elseif combination and split them into showing first the message and then the comments again.

This is untested, though. You may need to edit some other things for this.

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/
ruijt
Regular
Posts: 16
Joined: Sun Mar 27, 2005 3:32 pm

... still not working

Post by ruijt »

I'm sorry but I just can't get it right. I tried this script you gave me but then nothing apears anymore in the popup window.
Isn't the name of this file commentpopup.tpl instead of form?
Can you please help me again...
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: ... still not working

Post by garvinhicking »

I'm sorry, I mistyped it, you are right. The file you need is 'commentpopup.tpl'.

I just changed 1 line of the pasted code above; please find that line (about the middle, the if-structures) and only change that line instead of pasting the whole code to the file.

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/
ruijt
Regular
Posts: 16
Joined: Sun Mar 27, 2005 3:32 pm

Post by ruijt »

I'm really sorry but I tried the changes you made to the script, but still after submitting the comment, I get this message instead of the comments:

Your comment was successfully added. Click here to return to the comments, and here to close this window.

I just don't want to see this message after submitting a comment.

Hopefully you can help me :) Thanks HEAPS!!!
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Insert those two lines:

Code: Select all

{assign var="is_showcomments" value="true"}
{assign var="is_comment_allowed" value="true"}
just after the {if $is_comment_added} block, so that the entire file looks like this:

Code: Select all

{if $is_xhtml}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{else}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
           "http://www.w3.org/TR/html4/loose.dtd">
{/if}

<html>
<head>
    <title>{$head_title|@default:$blogTitle} {if $head_subtitle} - {$head_subtitle}{/if}</title>
    <meta http-equiv="Content-Type" content="text/html; charset={$head_charset}" />
    <meta name="Powered-By" content="Serendipity v.{$head_version}" />
    <link rel="stylesheet" type="text/css" href="{$serendipityHTTPPath}serendipity.css.php" />
    <link rel="alternate"  type="application/rss+xml" title="{$blogTitle} RSS feed" href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/index.rss2" />
    <link rel="alternate"  type="application/x.atom+xml"  title="{$blogTitle} Atom feed"  href="{$serendipityBaseURL}{$serendipityRewritePrefix}feeds/atom.xml" />
</head>

<body class="s9y_wrap" id="serendipity_comment_page">

{if $is_comment_added}

    {$CONST.COMMENT_ADDED}{$comment_string.0}<a href="{$comment_url}">{$comment_string.1}</a>{$comment_string.2}<a href="#" onclick="self.close()">{$comment_string.3}</a>{$comment_string.4}
{assign var="is_showcomments" value="true"}
{assign var="is_comment_allowed" value="true"}

{elseif $is_comment_notadded}

    {$CONST.COMMENT_NOT_ADDED}{$comment_string.0}<a href="{$comment_url}">{$comment_string.1}</a>{$comment_string.2}<a href="#" onclick="self.close()">{$comment_string.3}</a>{$comment_string.4}

{elseif $is_comment_empty}

    {$CONST.EMPTY_COMMENT}{$comment_string.0}<a href="#" onclick="history.go(-1)">{$comment_string.1}</a>

{elseif $is_showtrackbacks}

    <div class="serendipity_commentsTitle">{$CONST.TRACKBACKS}</div><br />
    <dl>
        <dt><b>{$CONST.TRACKBACK_SPECIFIC}:</b><br /></dt>
        <dd><a rel="nofollow" href="{$comment_url}">{$comment_url}</a><br /></dd>

        <dt><b>{$CONST.DIRECT_LINK}:</b><br /></dt>
        <dd><a href="{$comment_entryurl}">{$comment_entryurl}</a></dd>
    </dl>

    {serendipity_printTrackbacks entry=$entry_id}

{/if}
{if $is_showcomments}

    <div class="serendipity_commentsTitle">{$CONST.COMMENTS}</div>

    {serendipity_printComments entry=$entry_id}
    {if $is_comment_allowed}
        <div class="serendipity_commentsTitle">{$CONST.ADD_COMMENT}</div>
        {$COMMENTFORM}
    {else}
        <div class="serendipity_center serendipity_msg_important">{$CONST.COMMENTS_CLOSED}</div>
    {/if}

{/if}

</body>
</html>
HTH,
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/
ruijt
Regular
Posts: 16
Joined: Sun Mar 27, 2005 3:32 pm

Almost there

Post by ruijt »

Yes! Almost there :)
I removed also the complete message in the block, so the only thing in there is:

{if $is_comment_added}

{assign var="is_showcomments" value="true"}
{assign var="is_comment_allowed" value="true"}

The only thing missing is the commentform underneath it. Is there also an easy rule for that bit?

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

Re: Almost there

Post by garvinhicking »

Rujt, great.

About the commentform, that is actually a bit harder to do.

But I still post it. :)

1. Create a 'config.inc.php' file inside your template directory. There insert this code:

Code: Select all

function serendipity_smarty_displayCommentForm($params, &$smarty) {
global $serendipity;
        $query = "SELECT id, last_modified, timestamp, allow_comments, moderate_comments FROM {$serendipity['dbPrefix']}entries WHERE id = '" . $params['id'] . "'";
        $ca    = serendipity_db_query($query, true);
    return serendipity_displayCommentForm($params['id'], '?', NULL, $serendipity['POST'], true, $ca['moderate'], ca);
}

$serendipity['smarty']->register_function('serendipity_displayCommentForm', 'serendipity_smarty_displayCommentForm');
2. After the two {assign} calls in your commentpopup.tpl code add this:

Code: Select all

{serendipity_displayCommentForm id=$entry_id}
Then you're done :)
# 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/
ruijt
Regular
Posts: 16
Joined: Sun Mar 27, 2005 3:32 pm

Damn...

Post by ruijt »

Sorry mate... I really appreciate your time and effort, but this didn't work. Don't know what it does, but the function came right under the commentpopup link in an entry. Like this:

Comments(1)
function serendipity_smarty_displayCommentForm($params, &$smarty) { global $serendipity; $query = "SELECT id, last_modified, timestamp, allow_comments, moderate_comments FROM {$serendipity['dbPrefix']}entries WHERE id = '" . $params['id'] . "'"; $ca = serendipity_db_query($query, true); return serendipity_displayCommentForm($params['id'], '?', NULL, $serendipity['POST'], true, $ca['moderate'], ca); } $serendipity['smarty']->register_function('serendipity_displayCommentForm', 'serendipity_smarty_displayCommentForm');

Do I need to install anything extra for this function? SMARTY of something?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Damn...

Post by garvinhicking »

Oh, I'm sorry. I forgot to mention the <?php and ?> tags in the config.inc.php file! Add them at the top and bottom of the file, and then it should work:

Code: Select all

<?php
function serendipity_smarty_displayCommentForm($params, &$smarty) {
global $serendipity;
        $query = "SELECT id, last_modified, timestamp, allow_comments, moderate_comments FROM {$serendipity['dbPrefix']}entries WHERE id = '" . $params['id'] . "'";
        $ca    = serendipity_db_query($query, true);
    return serendipity_displayCommentForm($params['id'], '?', NULL, $serendipity['POST'], true, $ca['moderate'], ca);
}

$serendipity['smarty']->register_function('serendipity_displayCommentForm', 'serendipity_smarty_displayCommentForm'); 
?>
# 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