Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Comment Preview / Comment Error switching.
I’ve been over this before, but still haven’t found the right combination of code. Can I get a little help.
GOAL- If there is a comments error, show the error and NOT the preview.
- If there is not a comments error, show the preview as one would expect.
IN MY PAGE
<txp:if_individual_article>
<txp:article form="comments_display" />
</txp:if_individual_article>
IN COMMENTS DISPLAY
<h2 id="comment" class="ir">Comments</h2>
<txp:if_comments>
<div class="post">
<txp:comments />
</div>
</txp:if_comments>
<txp:if_comments_error>
<h3 id="cpreview" class="error">The field/s marked in orange below need to be fixed before the form can be processed.</h3>
<txp:comments_error wraptag="ul" break="li" />
<txp:else />
<txp:if_comments_preview>
<div id="cpreview">
<h3 class="note">This is only a preview of your comment, make changes, or <a href="#publish">submit</a> your comment to finish.</h3>
<txp:comments_preview />
</div>
</txp:if_comments_preview>
</txp:if_comments_error>
<txp:if_comments_allowed>
<txp:comments_form />
<txp:else />
<txp:if_comments>
<p>Sorry, comments have expired for this article, feel free to send me <txp:email email="squaredeye@gmail.com" linktext="an email" title="send me a good one" /> if you have some thoughts you'd like to share.</p>
<txp:else />
<p>I've left comments off for this article, but if you've got something add or say, feel free to send me <txp:email email="squaredeye@gmail.com" linktext="an email" title="send me a good one" />.</p>
</txp:if_comments>
</txp:if_comments_allowed>
MY COMMENTS FORM
<ul class="contact">
<li><label class="left">Name *</label>
<txp:comment_name_input /></li>
<li><label class="left">Email *</label>
<txp:comment_email_input /></li>
<li><label class="left">Website</label>
<txp:comment_web_input /></li>
<li><label id="comment_label" class="left">Comment *</label>
<txp:comment_message_input />
<p class="comments_help">
Fields marked with an [ * ] are required<br />
You may use <a href="http://textism.com/tools/textile/">Textile</a> to style your comments.
</p>
</li>
<li id="publish">
<txp:if_comments_preview>
<span class="preview"><txp:comment_preview /></span>
<txp:comment_submit />
<txp:else />
<txp:comment_preview />
</txp:if_comments_preview>
</li>
</ul>
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
Re: Comment Preview / Comment Error switching.
Can you try the following code? (replace at the end of your comment form)
<li id="publish">
<txp:if_comments_error>
<txp:else />
<txp:if_comments_preview>
<span class="preview"><txp:comment_preview /></span>
<txp:comment_submit />
<txp:else />
<txp:comment_preview />
</txp:if_comments_preview>
</txp:if_comments_error>
</li>
</ul>
But (thinking loud) if you hide the comment preview, how can the commenter “see” the error? (yes, you are telling which are the errors, but maybe they need to “see” them)
Offline
Re: Comment Preview / Comment Error switching.
Manaqui,
Actually that part is working just fine :)
I’m simply giving the preview button a new class dependent on whether on not the form is in preview mode. I’m doing a write up on it at squared eye as soon as it launches. In the meantime, its the comments_preview (note the s), that I want to hide. (poor naming convention, but oh well).
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
Re: Comment Preview / Comment Error switching.
anyone else have some thoughts?
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#5 2007-04-13 04:20:35
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Comment Preview / Comment Error switching.
Off the top of my head…
comments_display:
<h2 id="comment" class="ir">Comments</h2>
<txp:if_comments>
<div class="post">
<txp:comments />
</div>
</txp:if_comments>
<txp:if_comments_allowed>
<txp:comments_form show_preview="0" />
<txp:else />
<txp:if_comments>
<p>Sorry, comments have expired for this article, feel free to send me <txp:email email="squaredeye@gmail.com" linktext="an email" title="send me a good one" /> if you have some thoughts you'd like to share.</p>
<txp:else />
<p>I've left comments off for this article, but if you've got something add or say, feel free to send me <txp:email email="squaredeye@gmail.com" linktext="an email" title="send me a good one" />.</p>
</txp:if_comments>
</txp:if_comments_allowed>
comments_form:
<txp:if_comments_error>
<h3 id="cpreview" class="error">The field/s marked in orange below need to be fixed before the form can be processed.</h3>
<txp:comments_error wraptag="ul" break="li" />
<txp:else />
<txp:if_comments_preview>
<h3 id="cpreview" class="note">This is only a preview of your comment, make changes, or <a href="#publish">submit</a> your comment to finish.</h3>
</txp:if_comments_preview>
</txp:if_comments_error>
<ul class="contact">
<li><label class="left">Name *</label>
<txp:comment_name_input /></li>
<li><label class="left">Email *</label>
<txp:comment_email_input /></li>
<li><label class="left">Website</label>
<txp:comment_web_input /></li>
<li><label id="comment_label" class="left">Comment *</label>
<txp:comment_message_input />
<p class="comments_help">Fields marked with an [ * ] are required<br />
You may use <a href="http://textile.thresholdstate.com/">Textile</a> to style your comments.</p></li>
<li id="publish">
<txp:if_comments_error>
<txp:else />
<txp:if_comments_preview>
<div id="cpreview">
<span class="preview"><txp:comment_preview /></span>
</div>
<txp:comment_submit />
<txp:else />
<txp:comment_preview />
</txp:if_comments_preview>
</txp:if_comments_error>
</li>
</ul>
Last edited by Mary (2007-04-13 20:35:23)
Offline
Re: Comment Preview / Comment Error switching.
Mary,
You’re coming across the same problem I did. This setup doesn’t work. The else statement for the error produces the preview when the form hasn’t even been filled out yet. Any other ideas? Nesting them doesn’t seem to work as you’d expect.
<txp:if_comments_error>
<h3 id="cpreview" class="error">The field/s marked in orange below need to be fixed before the form can be processed.</h3>
<txp:comments_error wraptag="ul" break="li" />
<txp:else />
<h3 id="cpreview" class="note">This is only a preview of your comment, make changes, or <a href="#publish">submit</a> your comment to finish.</h3>
</txp:if_comments_error>
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline
#7 2007-04-13 20:39:36
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Comment Preview / Comment Error switching.
Try the updated comments_form code above.
Offline
Re: Comment Preview / Comment Error switching.
Mary,
Close :), It was right on, accept for the #publish, which I had correct before.
Thanks for your help :)
Matthew
So it looks like this:
COMMENT FORM
<txp:if_comments_error>
<h3 id="cpreview" class="error">The field/s marked in orange below need to be fixed before the form can be processed.</h3>
<txp:comments_error wraptag="ul" break="li" />
<txp:else />
<txp:if_comments_preview>
<h3 id="cpreview" class="note">This is only a preview of your comment, make changes, or <a href="#publish">submit</a> your comment to finish.</h3>
</txp:if_comments_preview>
</txp:if_comments_error>
<ul class="contact">
<li><label class="left">Name *</label>
<txp:comment_name_input /></li>
<li><label class="left">Email *</label>
<txp:comment_email_input /></li>
<li><label class="left">Website</label>
<txp:comment_web_input /></li>
<li><label id="comment_label" class="left">Comment *</label>
<txp:comment_message_input />
<p class="comments_help">Fields marked with an [ * ] are required<br />
You may use <a href="http://textile.thresholdstate.com/">Textile</a> to style your comments.</p></li>
<li id="publish">
<txp:if_comments_preview>
<span class="preview"><txp:comment_preview /></span>
<txp:comment_submit />
<txp:else />
<txp:comment_preview />
</txp:if_comments_preview>
</li>
</ul>
COMMENTS_DISPLAY
<h2 id="comment" class="ir">Comments</h2>
<txp:if_comments>
<div class="post">
<txp:comments />
</div>
</txp:if_comments>
<txp:if_comments_allowed>
<txp:comments_form show_preview="0" />
<txp:else />
<txp:if_comments>
<p>Sorry, comments have expired for this article, feel free to send me <txp:email email="squaredeye@gmail.com" linktext="an email" title="send me a good one" /> if you have some thoughts you'd like to share.</p>
<txp:else />
<p>I've left comments off for this article, but if you've got something add or say, feel free to send me <txp:email email="squaredeye@gmail.com" linktext="an email" title="send me a good one" />.</p>
</txp:if_comments>
</txp:if_comments_allowed>
- I am Squared Eye and I
am launchinghave launched Pattern Tap
Offline