Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
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
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
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
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
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
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
Pages: 1