Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-02-17 01:54:57

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,120
Website Mastodon

output txp:body and txp:exceprt to different parts of a page

Is it possible to output the body and the except of an article to two different areas of a page?

would i simply enter :

<txp:article>
<h1><txp:title /></h1>
	<txp:body />
<txp:article  />

in one Div and then in another Div have:

<txp:article>
	<txp:excerpt />
<txp:article  />

or would i have to use some custom id in the two different areas for example.

<txp:article_custom id="1" form="body_output />
and
<txp:article_custom id="1" form="excerpt_output />

or something else ?


…. texted postive

Offline

#2 2014-02-17 03:37:45

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,477

Re: output txp:body and txp:exceprt to different parts of a page

Both versions can work. It depends on the context.

Why don’t you simply try it? So you see the result and can give you the answer yourself.

Offline

#3 2014-02-17 04:39:11

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,120
Website Mastodon

Re: output txp:body and txp:exceprt to different parts of a page

GugUser wrote #279004:

Both versions can work. It depends on the context.

Why don’t you simply try it? So you see the result and can give you the answer yourself.

thanks for the nudge! I was pleasantly surprised – t the first option works great. i call it from a form “excerpt_side


…. texted postive

Offline

#4 2014-02-17 04:51:14

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: output txp:body and txp:exceprt to different parts of a page

bici – Your are using an opening article tag to open your tag set, which is correct if you are using it as a wrap tag, then closing your tag set with a self closing tag rather than a wrap tag closing tag; the results could be unpredictable that way especially if you are using multiple article tags in the same page.

Offline

#5 2014-02-17 04:57:59

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,120
Website Mastodon

Re: output txp:body and txp:exceprt to different parts of a page

rsilletti wrote #279006:

bici – Your are using an opening article tag to open your tag set, which is correct if you are using it as a wrap tag, then closing your tag set with a self closing tag rather than a wrap tag closing tag; the results could be unpredictable that way especially if you are using multiple article tags in the same page.

Thanks for the heads up. I am using two article tags on every page. One for Body and Title and the other for the excerpt How should i close the excerpt example or should i have it as unclosed?

Last edited by bici (2014-02-17 06:32:07)


…. texted postive

Offline

#6 2014-02-17 07:36:46

rsilletti
Moderator
From: Spokane WA
Registered: 2004-04-28
Posts: 707

Re: output txp:body and txp:exceprt to different parts of a page

I would use article_custom if you are using more than 1 tag per page, depending on how many articles you are returning with the article tag it can get complicated.
Tags tutorials.

Offline

#7 2014-02-17 08:24:54

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,786
Website GitHub

Re: output txp:body and txp:exceprt to different parts of a page

bici wrote #279003:

Is it possible to output the body and the except of an article to two different areas of a page?

Might be a naive observation, but can’t you do this:

<txp:article>
   <div class="blockOne">
      <h1><txp:title /></h1>
      <txp:body />
   </div>
   <div class="blockTwo">
      <txp:excerpt />
   </div>
</txp:article>

It doesn’t matter where the article tag occurs: everything inside it is in “article context” so all Txp tags work. The downside is you have to use the same Form to process both segments, but with some conditional code in your Form you could maybe get round that.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2014-02-17 10:47:21

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,315

Re: output txp:body and txp:exceprt to different parts of a page

bici wrote #279007:

Thanks for the heads up. I am using two article tags on every page. One for Body and Title and the other for the excerpt How should i close the excerpt example or should i have it as unclosed?

bici, what rsiletti pointed out was the slash at the very end of both your code snippets. So, instead of <txp:article /> you should close your tags properly by using </txp:article> (slash to the front).

Edit: Added link.

Last edited by uli (2014-02-17 10:52:21)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#9 2014-02-17 22:34:09

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,120
Website Mastodon

Re: output txp:body and txp:exceprt to different parts of a page

Bloke wrote #279013:

Might be a naive observation, but can’t you do this:

<txp:article>...

It doesn’t matter where the article tag occurs: everything inside it is in “article context” so all Txp tags work. The downside is you have to use the same Form to process both segments, but with some conditional code in your Form you could maybe get round that.

;-)) dead simple and the way that i thought it would work… but failed to try.


…. texted postive

Offline

#10 2014-02-17 22:36:56

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,120
Website Mastodon

Re: output txp:body and txp:exceprt to different parts of a page

uli wrote #279017:

bici, what rsiletti pointed out was the slash at the very end of both your code snippets. So, instead of <txp:article /> you should close your tags properly by using </txp:article> (slash to the front).

Edit: Added link.

right! failed to see what i had done…. .thanks again.


…. texted postive

Offline

Board footer

Powered by FluxBB