Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-12-28 14:35:47

Dimitri
Member
From: Johannesburg
Registered: 2010-10-31
Posts: 129

[request] using if conditional tags with the addressbar (URL)

I am struggling to set up some things.

I have experience in Expressionengine, if the url goes like this
www.example.com/gallery/album1 (just an example)

The /album1 is a name of a category

Txp seriously need a tag to fetch the url into the page like this, (my idea for TXP from EE)
<txp:if_segment_1=="gallery">blah blah</txp:if_segment_1>
or
<txp:if_segment_2=="{category}">blah blah</txp:if_segment_2>
so it easier to work with url like this
www.example.com/segment_1/segment_2/segement_3

You can even use that
<txp:if_segment_1!=“gallery”> (not equal because of != instead of ==) Blah blah
<txp:else/> blah2 blah2
</txp:if_segment_1>

So it doesnt matter what section, image, article it going to be. Its more flexible for lots of things, even any type of Permanent link mode you have chosen.

Maybe it will be nice addition for everyone or TXP5 :P

See example here
Link

Conditional example tags here
Link

*******

I work with EE by day, Textpattern freelancing by night.

BTW, I love Txp.

Please provide back with any opinions/feedbacks/blah/blah2

Thanx


<txp:way_too_cool />

Offline

#2 2010-12-28 14:56:42

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: [request] using if conditional tags with the addressbar (URL)

It’s better for portability to use the built-in conditional tags (if_category, if_section, if_article_id, if_search, etc.) rather than direct URL parsing. Then you can change permanent link mode without breaking things.


Code is topiary

Offline

#3 2010-12-28 15:27:54

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: [request] using if conditional tags with the addressbar (URL)

While not quite the same, but there is also txp:page_url (which you can use with txp:variable / txp:if_variable) and adi_gps.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2010-12-28 16:00:03

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: [request] using if conditional tags with the addressbar (URL)

And there is also gbp_permanent_links (beware, no help docs, so you will have to figure out stuff by reading —or asking at— the plugin thread or by trial/error).

While gbp_permanent_links most known/important/commonly-used feature is to let you generate other URL schemes, there is a somewhat hidden feature that lets you assign different page templates to different URL schemes.

Example: for you /gallery/ section you could use the “gallery” page template, and for your /gallery/album1 you could use the “gallery-album” page template.
This approach has the advantage, imho, of making templates less cluttered of conditionals (if_article_list, if_category, and others). It has the “disadvantage” or requiring a plugin, and having to create/maintain a few more templates.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2010-12-28 23:01:16

Dimitri
Member
From: Johannesburg
Registered: 2010-10-31
Posts: 129

Re: [request] using if conditional tags with the addressbar (URL)

mmm, gbp_permanent_links looks interesting, I will have a spin with it soon. I am trying hard to avoid <txp:variable/>

I think it time for me to shift my status of php skills from below-average noob to above-average noob to achieve full understanding to use those.

Thanks for pointing the direction.

Last edited by Dimitri (2010-12-28 23:01:34)


<txp:way_too_cool />

Offline

Board footer

Powered by FluxBB