I'd like to visual mark the user's preview comment so that it appears differently from the rest of the comment history. But it seems that serendipity_smarty_printComments just appends the preview onto the end of the rest of the comments with no hook my template could use to apply a different class or whatever.
Is there another way to go about this? One way to get what I want is to have a conditional in comments.tpl, similar to that used for distinguishing author comments:
{if $comment.author == $entry.author}<div class="mycomment">{else}<div class="comment">{/if}
But I might also want to change the location of the preview comments in the document flow, something roughly like this (in entries.tpl):
<h2>Comments:</h2>
{serendipity_printCommentsNoPreview entry=$entry.id mode=$entry.viewmode}
<h2>Your comment (preview):</h2>
{serendipity_printPreviewComment entry=$entry.id mode=$entry.viewmode}
I could write this, but I obviously don't want to fork s9y. Is there another way to iterate over the comments? Should I do this in a plugin instead? Thanks!
Distinguishing preview comment from other comments
Re: Distinguishing preview comment from other comments
Theoretically, i.e. untested, this should be doable with CSS only. Assuming default/comments.tpl, any comment gets assigned an id:eikimart wrote:I'd like to visual mark the user's preview comment so that it appears differently from the rest of the comment history.
Code: Select all
<div id="serendipity_comment_{$comment.id}" [...]
YL
-
- Core Developer
- Posts: 30022
- Joined: Tue Sep 16, 2003 9:45 pm
- Location: Cologne, Germany
- Contact:
Re: Distinguishing preview comment from other comments
Hi!
Also, you wouldn't necessarily fork core features; you could create your custom function in the template's config.inc.php file, and since the user's comment is stored in $serendipity['POST'] you could access it to be printed "outside" of the usual flow (in addition to the normal s9y flow, though - if needed you could work around that though with some more code).
The comment addition BTW happens in include/functions_smarty.inc.php, serendipity_smarty_printComments - it just appends $comments[] with the POSTed data.
However, that what yellowled mentions should work as well, and you could even use jQuery (if you want) to reposition the element within the DOM - that would be the less complex, but maybe easiest approach.
Regards,
Garvin
Also, you wouldn't necessarily fork core features; you could create your custom function in the template's config.inc.php file, and since the user's comment is stored in $serendipity['POST'] you could access it to be printed "outside" of the usual flow (in addition to the normal s9y flow, though - if needed you could work around that though with some more code).
The comment addition BTW happens in include/functions_smarty.inc.php, serendipity_smarty_printComments - it just appends $comments[] with the POSTed data.
However, that what yellowled mentions should work as well, and you could even use jQuery (if you want) to reposition the element within the DOM - that would be the less complex, but maybe easiest approach.
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/
# 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/
Re: Distinguishing preview comment from other comments
That's an awesome idea given that a lot of people complain about the fact that S9y doesn't automagically scroll to the preview. We should definitely keep that in mind for future versions.garvinhicking wrote:However, that what yellowled mentions should work as well, and you could even use jQuery (if you want) to reposition the element within the DOM - that would be the less complex, but maybe easiest approach.
YL