Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-01-04 23:53:52

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,381
GitHub

When is a section not a section - <txp:if_section>

Hi there.
It might just be a late night brain malfunction, but I’m scratching my head over this one.

<txp:if_section>
section
<txp:else />
not a section
</txp:if_section>

My logic says that if the page being viewed is a section, then it should display ‘section’ (minus quotes), and if not, display ‘not a section’ (minus quotes). The site in question (http://bleepshow.com/) has a slew of sections set up and they’re all viewable via a browser, yet only the front page (default) triggers the ‘section’ marker. The code above is outside any <txp:article> tags, and I can’t fathom it out.

Off for a Jagermeister on ice to see if that helps…

Any advice gratefully received. Thanks!

Pete

Edit: forgot to say – 4.0.5 in action, diagnostics check out fine:

Textpattern version: 4.0.5 (r2466)
Last Update: 2007-09-14 21:57:58/2007-09-14 21:49:16
Document root: /home/bleepshow.com/web/public
$path_to_site: /home/bleepshow.com/web/public
Textpattern path: /home/bleepshow.com/web/public/textpattern
Permanent link mode: year_month_day_title
Temporary directory path: /var/tmp
Site URL: www.bleepshow.com
TZ: GMT
PHP version: 5.2.1
GD Image Library: 2.0 or higher; supported formats: GIF, JPG, PNG.
Server Local Time: 2008-01-04 23:54:55
MySQL: 5.0.37-log
Locale: C
Server: Apache
Apache version: Apache
PHP Server API: apache2handler
RFC 2616 headers:
Server OS: SunOS 5.11
Active plugins: asy_sitemap-0.7, jnm_audio-0.3

.htaccess file contents:
————————————
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) – [PT,L]

RewriteRule ^(.*) index.php </IfModule>

php_value register_globals off

————————————

Last edited by gaekwad (2008-01-05 00:02:58)

Offline

#2 2008-01-05 00:16:01

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: When is a section not a section - <txp:if_section>

Usually you have to specify a “name” attribute.
If you don’t specify one, I think the tag uses as a default the “default” section (your home page).
So your code is equivalent to:

<txp:if_section name="default">
section
<txp:else />
not a section
</txp:if_section>

Offline

#3 2008-01-05 00:35:36

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,381
GitHub

Re: When is a section not a section - <txp:if_section>

Perfect! Thank you, redbot – you’re exactly right.

Offline

#4 2008-01-05 01:25:45

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: When is a section not a section - <txp:if_section>

If you don’t specify one, I think the tag uses as a default the “default” section (your home page).

Actually the default section (aka frontpage) is empty, as it isn’t real excutable section.

<txp:if_section name="">
We are on frontpage
<txp:else />
Yeah, now we are browsing awasome section
</txp:if_section>

And with multiple sections:

<txp:if_section name=",blog,articles"></txp:if_section>

Cheers!

Last edited by Gocom (2008-01-05 01:30:08)

Offline

#5 2008-01-05 11:45:21

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: When is a section not a section - <txp:if_section>

True enough Jukka but I tend to find using “default” more visible when looking through the code, particularly with comma-separated lists like your second example.

Last edited by thebombsite (2008-01-05 11:46:05)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#6 2008-01-06 03:25:14

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: When is a section not a section - <txp:if_section>

if_section understands “” and “default” as the same thing.

You’re always in a section, the tag is for determing which one you’re in.

Last edited by Mary (2008-01-06 03:25:40)

Offline

Board footer

Powered by FluxBB