Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2015-09-03 20:05:56
- pierlu
- Member
- Registered: 2014-08-12
- Posts: 153
Form articolo
For an article of the site I have created this form but I don’t see some result why?
txp
<txp:if_article_list>
<div class="article">
<h1>Un'emozione per sempre</h1>
<txp:excerpt />
<txp:else /><txp:permlink class="em">Leggi tutto</txp:permlink>
<txp:article_image escape="" thumbnail="0" />
<txp:body />
</div>
</txp_if_article_list>
EDIT: Proper code display
Last edited by jakob (2015-09-03 20:34:00)
Offline
Re: Form articolo
pierlu,
You have more information available to answer “why” than we do.
Therefore, your best choices are:
- you tell us why it does not work or
- provide more information with your question(s)
Last edited by maverick (2015-09-03 20:15:28)
Offline
#3 2015-09-04 00:01:59
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: Form articolo
<txp:if_article_list>
<!-- That's the own space for the complete code related to the article list, I mean THE COMPLETE CODE -->
<txp:else />
<!-- That's the own space for the complete code related to the individual article, I mean THE COMPLETE CODE -->
</txp:if_article_list>
Offline
Re: Form articolo
GugUser wrote #294498:
GugUser – Point well made. But it still should have shown something. It seems there is more at play than just incomplete code?
Offline
#5 2015-09-04 03:20:20
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: Form articolo
The example by pierlu shows two errors:
- The close tag isn’t correct:
</txp_if_article_list>
- The
div
is opened in the article list part and closed in the individual article part.
Offline
#6 2015-09-04 08:53:18
- pierlu
- Member
- Registered: 2014-08-12
- Posts: 153
Re: Form articolo
<txp:if_article_list>
<div class="article">
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<txp:excerpt />
<txp:permlink class="em">Leggi tutto</txp:permlink> </div>
<txp:else />
<txp:article_image escape="" thumbnail="0" />
<txp:body />
</txp_if_article_list>
is ok?
Last edited by ruud (2015-09-04 09:38:17)
Offline
Re: Form articolo
No, that’s not resolved it yet. There are a couple of things you can do to help discover problems yourself:
- When you write code, indent tag-pairs, so you can see what tags belong together. That helps you see what doesn’t match.
- Look at the source code that your tags produce in the browser. That helps you discover what is wrong with the output (e.g. you’d discover the div problem).
- Read the tips in the forum carefully – They help you identify the problem:
- GugUser gave you two important tips: you have a typing mistake in your closing article_list tag and your opening
<div…
and closing</div>
are in different parts of yourif
-logic, so you’ll only ever see one of them - Maverick also asked you to show us the code you use to call this snippet. That’s relevant – see below.
- GugUser gave you two important tips: you have a typing mistake in your closing article_list tag and your opening
For example, this is how it (probably) should be:
<div class="article">
<txp:if_article_list>
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<txp:excerpt />
<txp:permlink class="em">Leggi tutto</txp:permlink>
<txp:else />
<txp:article_image escape="" thumbnail="0" />
<txp:body />
</txp:if_article_list>
</div>
Corrected:
- The closing tag also has to start with a colon:
</txp:…
– you had an underscore. - The
<div class="article"> … </div>
is a container. Your if_article / if_individual method meant that only the start or the end div would display but never both.
As Maverick asked, how are calling this form? If you are using txp:article
, you can split this form into two forms: one for the list view and one for the individual article view, and let txp:article decide which to use, depending on the page you are viewing. Example:
<txp:article form="article_layout_single" listform="article_layout_list" />
You would then have two forms, for example article_layout_list
:
<div class="article-teaser">
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<txp:excerpt />
<txp:permlink class="em">Leggi tutto</txp:permlink>
</div>
And article_layout_single
as follows:
<div class="article">
<h1><txp:title /></h1>
<txp:article_image escape="" thumbnail="0" />
<txp:body />
</div>
With this modular approach, each form does just the task it needs to do – the display logic of when to display which form is handled by the txp:article tag and makes the form easier to design.
Edited to correct extra div spotted by GugUser. Thanks!
Last edited by jakob (2015-09-04 19:53:18)
TXP Builders – finely-crafted code, design and txp
Offline
Re: Form articolo
GugUser wrote #294500:
The example by pierlu shows two errors:
- The close tag isn’t correct:
</txp_if_article_list>
- The
div
is opened in the article list part and closed in the individual article part.
GugUser – good catch on the close tag. I was multi-tasking when I looked at the code, and I kept thinking something was off, but it wasn’t registering as to what. You are correct that would have kept anything from showing. My apologies.
Offline
#9 2015-09-04 15:49:35
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: Form articolo
In jakob’s example for the “article_layout_list” form there is a </div>
to much.
Offline
#10 2015-09-04 15:51:30
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: Form articolo
The same in this example:
<div class="article">
<txp:if_article_list>
<h1><txp:permlink><txp:title /></txp:permlink></h1>
<txp:excerpt />
<txp:permlink class="em">Leggi tutto</txp:permlink> </div>
<txp:else />
<txp:article_image escape="" thumbnail="0" />
<txp:body />
</txp:if_article_list>
</div>
Offline
Re: Form articolo
Gaah, I copied the original code and overlooked that.
Thanks GugUser, I’ve corrected it in the above post and noted your input.
But it reinforces my point: writing code out clearly, with each line serving a particular purpose makes it easier to follow.
TXP Builders – finely-crafted code, design and txp
Offline
Pages: 1