Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-07-06 18:13:41

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

if_comments_error usage

Hi,

Is it correct that the <txp:if_comments_error> tag can only be used within the form named ‘comment_form’? I’d like to use it within the ‘comments’ form instead but it does not seem to work.

Primary reason for this is to stop the comment preview from ever appearing if there is an still an error in the submission form – it looks a bit rubbish if you can preview a half-completed comment with, for example, the authors name missing.

I know I could put the <txp:comment_preview> tag with the comment_form itself and then use the if_comments_error that way but for the layout I have (comments in an ordered list where the preview is the last one numerically) that is not what I want to do.

Offline

#2 2011-07-07 09:25:45

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: if_comments_error usage

philwareham wrote:

Is it correct that the <txp:if_comments_error> tag can only be used within the form named ‘comment_form’? I’d like to use it within the ‘comments’ form instead but it does not seem to work.

Yes. The tag can only be used after <txp:comments_form /> has been called. It’s not restricted to the form, but to the tag. Means that If_comments_error can be used either wrapped in comments_form tag (if used in container form), inside the specified form (defaults to comment_form if no form is specified) or after the tag.

I know I could put the <txp:comment_preview> tag with the comment_form itself and then use the if_comments_error that way but for the layout I have (comments in an ordered list where the preview is the last one numerically) that is not what I want to do.

You could use variables to move the output where you need it, or you could put everything inside the <txp:comments_form /> block, including the list of comments.

If you want to use variables, just throw the comment form into variable, and then wrap the comment preview (including the conditional statement) to other. Like a matryoshka doll, but instead of dolls you have two variables. That way you can output the comment form and comment preview anywhere you want.

Offline

#3 2011-07-07 09:32:20

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: if_comments_error usage

Thanks Gocom, this is for the TXP5 front-side theme so I need to keep it as simple as possible. Maybe I should just live with it as it is – but I’ll investigate your solutions first.

Cheers, Phil

Offline

Board footer

Powered by FluxBB