Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2013-10-12 15:45:14

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

Predict no comment form

I have a site where there is a small “sidebar” which is displayed vertically alongside the comment form when the form is displayed. If there is no form displayed the “sidebar” is displayed horizontally.

Now I can predict the display of the comment form in most situations using standard Textpattern tags however there is one situation where I can’t and that is when a visitor has just submitted a comment. Comments are, of course, still allowed so my sidebar displays vertically however there is no comment form displayed so it looks a bit stupid.

Is there some code I can use to predict this situation?

Last edited by thebombsite (2013-10-12 15:47:04)


Stuart

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

Offline

#2 2013-10-13 18:17:57

etc
Developer
Registered: 2010-11-11
Posts: 5,393
Website GitHub

Re: Predict no comment form

You can try to check if commented URL variable is set:

<txp:php>
	parse('<txp:variable name="commented" value="'.(isset($_GET['commented']) ? 'yes' : 'no').'" />');
</txp:php>

<txp:if_variable name="commented" value="yes">
	horizontal layout
<txp:else />
	vertical layout
</txp:if_variable>

Offline

#3 2013-10-13 20:59:31

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

Re: Predict no comment form

Thanks for that Oleg. I’ll give it a whirl in the morning.


Stuart

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

Offline

#4 2013-10-13 21:26:29

etc
Developer
Registered: 2010-11-11
Posts: 5,393
Website GitHub

Re: Predict no comment form

If your layout is purely CSS, another (dirty, but radical) solution could be including the appropriate <style> declarations directly in your comment_form.

Offline

#5 2013-10-15 17:06:17

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

Re: Predict no comment form

I’ve used your first suggestion very successfully and can use it in several places at once seeing as it’s giving out a variable. I think I’ll leave your second possibility alone for now. Thanks.


Stuart

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

Offline

#6 2013-10-15 17:50:26

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

Re: Predict no comment form

You could simplify that down to, which avoids calling parser() function yourself:

<txp:variable name="commented"><txp:php>
    echo (int) (gps('commented') !== '');
</txp:php></txp:variable>

<txp:if_variable name="commented" value="1">
    <!-- preview -->
</txp:if_variable>

Its also better approach incase you are going to use the same snippet to extract other variables. Mixing PHP in Textpattern markup like that has the potency of leading into security issues, unless you are filtering the values beforehand. Never ever do it otherwise.

If you are using any plugins such as adi_gps, rah_function, smd_if, etc_query etc you could use that one too, since all of these are able to check HTTP GET params too.

Last edited by Gocom (2013-10-15 17:51:22)

Offline

#7 2013-10-15 17:56:48

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

Re: Predict no comment form

Thanks Jukka. I’ll look at the plugins if you feel that it’s safer.


Stuart

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

Offline

Board footer

Powered by FluxBB