Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2016-07-04 09:44:04
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,289
output form if article id is 145
…but it doesn’t. only that article is displayed.
page:
<txp:if_section name="club">
<section class="content-1">
<div class="container">
<txp:if_article_id id="145">
<txp:output_form form="zem_contact" />
<txp:else />
<txp:article status="sticky" />
<txp:article limit="50" time="any" />
</txp:if_article_id>
</div>
</section>
<txp:else />
...
Offline
#2 2016-07-04 10:07:52
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,289
Re: output form if article id is 145
ok, i get that:
The id attribute must be used in an article list context (when producing a page that displays more than one article) or the tag will do nothing.
but how to display that form at the end of that (id 145) article?
paste form directly into article is not an option.
Last edited by Gallex (2016-07-04 10:44:40)
Offline
#3 2016-07-04 13:02:53
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,304
Re: output form if article id is 145
I assume you’re not using it inside an article form/container.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: output form if article id is 145
Gallex wrote #300170:
but how to display that form at the end of that (id 145) article? Paste form directly into article is not an option.
A simpler option would be to paste <txp:output_form form="zem_contact" />
into the body of article id 145 after your text.
Alternatively, could you not do it with a variable:
<txp:if_individual_article>
<txp:variable name="this_id"><txp:article_id /></txp:variable>
<txp:if_variable name="this_id" value="145">
<txp:body /> <!-- if you need the article body first -->
<txp:output_form form="zem_contact" />
<txp:else />
…
</txp:if_variable>
</txp:if_individual_article>
I believe the article tags work without the wrapping txp:article
tag if you are explicitly in an individual article context.
TXP Builders – finely-crafted code, design and txp
Offline
#5 2016-07-05 09:14:14
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,289
Re: output form if article id is 145
jakob wrote #300173:
Alternatively, could you not do it with a variable:
<txp:if_individual_article>...
didn’t work – no form.
my permanent link mode is section/title
– could this be a reason?
Last edited by Gallex (2016-07-05 09:16:47)
Offline
Re: output form if article id is 145
No, there was a problem with the logic. Your id test is for an individual article but your else statement is for either a list or individual article. My suggestion broke that.
<txp:if_individual_article>
<!-- individual article -->
<txp:variable name="this_id"><txp:article_id /></txp:variable>
<txp:body />
<txp:if_variable name="this_id" value="145">
<txp:output_form form="zem_contact" />
</txp:if_variable>
<txp:else />
<!-- article list -->
<txp:article status="sticky" />
<txp:article limit="50" time="any" />
</txp:if_individual_article>
There’s an assumption here that your sticky article is just an intro text that is never called up as a distinct page. If that’s not true, you could perhaps do just this in your page template:
<txp:article status="sticky" form="article_form" />
<txp:article limit="50" time="any" form="article_form" />
and in your article_form
form you would do:
<txp:if_individual_article>
<!-- your single article output goes here -->
<txp:if_article_id id="145">
<txp:output_form form="zem_contact" />
</txp:if_variable>
<txp:else />
<!-- your list form output goes here -->
</txp:if_individual_article>
Again, if the if_article_id
will not work in the individual article context, then use the variable
and if_variable
method. You could also split the output into a form and listform if your prefer and specify those in your txp:article attributes.
TXP Builders – finely-crafted code, design and txp
Offline
#7 2016-07-05 11:21:18
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,289
Re: output form if article id is 145
jakob wrote #300192:
No, there was a problem with the logic. Your id test is for an individual article but your else statement is for either a list or individual article. My suggestion broke that.
<txp:if_individual_article>...
still variable
if_variable
method not working.
this is the page the form should appear.
looks to me, that code you provided, doesn’t affect article itself also: there should be no title, but it is…
Last edited by Gallex (2016-07-05 11:23:38)
Offline
Re: output form if article id is 145
Gallex wrote #300194:
still
variable
if_variable
method not working.
This section of the code (excerpted from above):
<txp:variable name="this_id"><txp:article_id /></txp:variable>
<txp:body />
<txp:if_variable name="this_id" value="145">
<txp:output_form form="zem_contact" />
</txp:if_variable>
will only show when you are on the page with id 145, otherwise you will see nothing. I often find it helpful when debugging to output the variable <txp:variable name="this_id" />
or to output text in the different parts of if_statements to help you know which part of the code has been reached and identify why a variable might not be being matched. If you’re not getting any output, try wrapping it in a <txp:article> … </txp:article>
(i.e. as a container tag).
looks to me, that code you provided, doesn’t affect article itself also: there should be no title, but it is…
If you don’t specify a form of your own, textpattern uses the default
form to output the article. That will have the title in it.
this is the page the form should appear.
That looks correct. Putting http://www.estbirding.ee/index.php?id=145
in the browser returns that page.
TXP Builders – finely-crafted code, design and txp
Offline
Re: output form if article id is 145
Hi
Gallex
You could also use the <txp:if_article_id id="145" />blah blah<txp:else />etc...
tag.
>Edited to add: There is another method which I am sure it might be easier. Use the override form
option on the write page of the article. In this way you can code a form (type: article in presentation>forms) with whatever content you may want to appear when visitors land on that page.
Last edited by colak (2016-07-05 15:22:31)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
#10 2016-07-06 09:46:44
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,289
Re: output form if article id is 145
colak wrote #300196:
There is another method which I am sure it might be easier. Use the
override form
option on the write page of the article. In this way you can code a form (type: article in presentation>forms) with whatever content you may want to appear when visitors land on that page.
brilliant!! thank you colak!
Offline
#11 2016-07-06 09:51:01
- Gallex
- Member
- Registered: 2006-10-08
- Posts: 1,289
Re: output form if article id is 145
jakob wrote #300195:
will only show when you are on the page with id 145, otherwise you will see nothing.
That looks correct. Puttinghttp://www.estbirding.ee/index.php?id=145
in the browser returns that page.
but like you saw, there was no contact form
Offline
Re: output form if article id is 145
It’s quite possible that I’ve made a mistake somewhere :-) but you really need to do some debugging to find out what bits of the code work and what don’t. The tag trace is a help, but I often simply add some text output to the different if situations, i.e. is individual article
, is article list
, is article 145
, in article form xyz
etc. and output the variable (with some delimiters before and after) to see a) if it’s actually being created and b) if it is producing output, why it doesn’t match the if_variable case. Usually, I discover the problem before I’m finished.
TXP Builders – finely-crafted code, design and txp
Offline
Pages: 1