Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-12-21 12:29:26

jeskoger
New Member
Registered: 2011-12-21
Posts: 4

Column Sektion?

hi,

I am very new to textpattern and I have run into a bit of a wall.

I am using textpattern on my site as an addin blog.

What I am trying to do, and where the problem lies, is on my Main page I have three equal columns set up each intended to “host” the article selection from each one of my three sections. My question now is how do I get this to work, i have tried it by posting this

<txp:if_article_section name="linklog">
	<!-- "linklog" section only -->
	<div class="linklog"><txp:body /></div>
<txp:else />
	<!-- all other sections -->
	<txp:title />

	<txp:body />
</txp:if_article_section>

into each of my three column divs, but no luck.

I hope someone can help me.

cheers,

Jesko

{Edited to add bc.. for better code display. -Uli}

Last edited by uli (2011-12-21 13:39:25)

Offline

#2 2011-12-21 13:54:10

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

Re: Column Sektion?

Edit: Sorry, pressed for time. Removed the whole complete nonsense.

Last edited by uli (2011-12-21 16:00:06)


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

Offline

#3 2011-12-21 15:13:33

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

Re: Column Sektion?

@ uli

Are you sure that <txp:article_custom> works with <txp:else />?

Offline

#4 2011-12-21 16:13:47

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: Column Sektion?

You can do that with either three separate sets of txp:article_custom (which allows you to bring in content from other sections), one for each section, or you can combine it with txp:section_list as follows.

<txp:section_list sections="linklog,section-b,section-c" break="">
   <txp:article_custom section='<txp:section />' limit="1">

   <div class="column<txp:if_section name="linklog"> linklog</txp:if_section>">
      <txp:if_section name="linklog"><txp:else /><h2><txp:title /></h2></txp:if_section>
      <txp:body />
   </div>

   </txp:article_custom>
</txp:section_list>

… and replace the section names in the first line with your section names. That will loop through your three sections and list 1 article (the most recent) for each of them, wrapped in a div. For the linklog section, the div is given an extra class, and the title is skipped (by making use of if else). Does that do what you want?


TXP Builders – finely-crafted code, design and txp

Offline

#5 2011-12-22 07:45:31

jeskoger
New Member
Registered: 2011-12-21
Posts: 4

Re: Column Sektion?

So its not working… nothing shows up and when i get something to show it shows all sektions in the same column. here is my html mark up.

<div id=“left”> <txp:article_custom section=’<txp:section />’ limit=“2”>

<txp:if_section name=“stuf”><txp:else /><h2><txp:title /></h2></txp:if_section> <txp:body /> </txp:article_custom>

</div>
<div id=“right”> <txp:article_custom section=’<txp:section />’ limit=“2”>

<txp:if_section name=“musings”><txp:else /><h2><txp:title /></h2></txp:if_section> <txp:body /> </txp:article_custom>

</div>
<div id=“middle”>

<txp:article_custom section=’<txp:section />’ limit=“2”> <txp:if_section name=“iterations”><txp:else /><h2><txp:title /></h2></txp:if_section> <txp:body /> </txp:article_custom> </div>

———

when i tried your code jakob it did work, only the sections were displayed on top of eachother, i want them arranged from left to right.

thank you all for your time and help

Offline

#6 2011-12-22 07:48:04

jeskoger
New Member
Registered: 2011-12-21
Posts: 4

Re: Column Sektion?

ahhh jakob you are a genius, i just had to edit the column in the css and now its displayed correctly…. Thank you

Offline

#7 2011-12-22 08:57:21

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: Column Sektion?

You see the attribute section='<txp:section />' (with single quotes around it)? That’s a tag-in-tag construction that means “insert the parsed result of that tag as the attribute”. <txp:section /> will output either the current page’s section (as per the url) or the current section in a section_list loop. If you want to do separate divs, you can do that too but you just need to specify the section you want in the section attribute, e.g. section="linklog" (use standard double-quotes for the attribute here as it doesn’t need to parse anything). You can then also omit the if_section tags because you’re already handling each case separately. By way of example:

<div id="left">
   <txp:article_custom section="stuf" limit="2">
      <h2><txp:title /></h2>
      <txp:body />
   </txp:article_custom>
</div>
<div id="right">
   <txp:article_custom section="musings" limit="2">
      <h2><txp:title /></h2>
      <txp:body />
   </txp:article_custom>
</div>
<div id="middle">
   <txp:article_custom section="iterations" limit="2">
      <!-- if you don't want a title, just leave out the tag -->
      <txp:body />
   </txp:article_custom>
</div>

The first code option I showed in the earlier post is perhaps more elegant and economical (and re-usable), the second is more explicit and therefore more readable.


TXP Builders – finely-crafted code, design and txp

Offline

#8 2011-12-22 11:08:16

jeskoger
New Member
Registered: 2011-12-21
Posts: 4

Re: Column Sektion?

so now i have a new problem.

I used the more practical method of displaying each section and it words very well. Now I tried to give each Colum the section title, behold I got one section title and for the rest it says, DEFAULT.

<txp:section/> is the markup I used.
you can see it here.
http://blog.chimeric-fusion.com/

Offline

#9 2011-12-22 16:49:08

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: Column Sektion?

With the first variant using txp:section_list it would work, but when <txp:section /> is not used within a section_list tag, it will show you your current section context – that is the current section you are in as shown in the url. On the home page that means you’ll see “default”.
Solution: Seeing as you’re hard-coding the title into the article_custom tag anyway, I’d take the shortcut and simply write the section title in plain HTML.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB