Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-11-01 22:53:23

thebombsite
Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

[howto] Using the new "if_comments_preview" tag.

With TXP 4.0.2 you have some new tags to play with for the comments side of things. The Dev Weblog gives an example of usage but I thought I would share mine. Here’s how my “comments_display” form looks:-

<txp:if_comments_preview>
<txp:comments_preview form="comments_preview" />
<txp:comments_form preview="1" />
<txp:else />
<txp:if_comments>
<h3 id="comment"><txp:comments_count /> Comments for <txp:title /></h3>
</txp:if_comments>
<txp:comments />
<txp:if_comments_allowed>
<txp:comments_form />
</txp:if_comments_allowed>
</txp:if_comments_preview>

So what does this produce? Let’s ignore the “if_comments_preview” block at the top for a moment. I should say that I have “auto append comments” switched on in Preferences and use the standard comments_invite tag in my article form.

The first thing is the h3 which is a title that appears above any comments. It will output something like “3 comments for My New Article”. It is surrounded by the “if_comments” tags which means that if there are NO comments it won’t appear. There is no need to surround the “comments” tag because if there are no comments none will appear anyway. :) So if there are comments I get a list with the title at the top and if there aren’t any I get nothing so the comment entry form would be immediately below the article.

Next, the “comments_form” tag is surrounded by the “if_comments_allowed” tags. This means if comments are off or they are time-limited and the time has expired the form won’t appear, otherwise it does.

Now you’ve understood all that let’s get to the new bit at the top. You will see that the “if_comments_preview” tags surround the complete form and there is an “else” tag in there, so we are either in comments preview and working with the top code block, else we are not in comments preview so we are working with the bottom block which I have explained above.

With the tags I am using, when in comment preview I see the article, followed by the comment preview, followed by the comment entry form. No other comments will be shown. When you click on the preview button there is a built-in anchor tag so that you see the comment preview at the top of the screen. The article is out of sight above it and the comment entry form is probably in view immediately below it. My “comments_preview” tag points to a form called “comments_preview” which looks similar to this (I’ve taken some “extras” out which have no bearing on this subject so as not to be confusing):-

<div id="cpreview">
<p class="preview">This is how your comment will appear when submitted.</p>
<div class="remarks">
<div class="commenter">Comment made by <txp:comment_name /> on <txp:comment_time /> <txp:comment_permlink>#</txp:comment_permlink></div>
<txp:message />
</div>
</div>

The id “cpreview” is the anchor I mentioned earlier and the p class “preview” is for a little message that will appear above the comment preview. You can call it what you like and change the text to suit your needs but don’t forget to add this stuff to your CSS for appropriate styling. Apart from these the form is identical to my default form so the comment preview will look exactly as it will when submitted apart from the added message above it.

(updated code display. -Els)

Last edited by Els (2009-09-27 12:47:25)


Stuart – The BombsiteProText ThemesTextgarden

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#2 2005-11-02 22:36:19

nardo
Member
From: tuvalahiti
Registered: 2004-04-22
Posts: 741

Re: [howto] Using the new "if_comments_preview" tag.

if you want to display your ‘previewed’ comment just as it will appear after submission, u can call the comments form itself…
<txp:comments_preview form="comments" />

and to reinforce the requirement to “submit”… now that the preview is in a unique box, u can dull the colour of the “preview” submit button via your stylesheet:
#cpreview input#preview {background-color:#999;}

don’t have an install handy, so this is from memory… the preview input button has an ID assigned, I’m pretty certain

Last edited by nardo (2005-11-02 22:39:50)

Offline

Board footer

Powered by FluxBB