Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-07-08 20:46:52

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

soo_if_frontpage: is this a section front page?

Similar to the glx_if_frontpage tag from the no-longer-supported “ glx_if plugin. Most of glx_if’s functionality is now available through core Txp tags, but not this (well, not without an absurd stack of conditional tags). To glx_if_frontpage it adds txp:else /> compatibility, and a couple of attributes for more control.

soo_if_frontpage evaluates to true if the current page context is:

  • an article list, and;
  • not search results, and;
  • not a listing of articles by category, and;
  • not a listing of articles by author, and;
  • not a listing of articles by month, and;
  • not an image page, and;
  • in one of the sections listed in section (defaults to the ‘default’ section only), and
  • (optionally) a single-page list or the first page of a multi-page list, if the pg attribute is set.

Note: as of version 0.1.4 you can use section="*" as a shortcut to include all sections (including default). Thanks to alanfluff for the feedback.

Information and download.

Why? I was cleaning out some Txp cruft and was going to get rid of this little plugin, which I’ve been using privately for years. But re-discovered that it is genuinely useful for at least one small but important situation: styling the Home link in a nav bar. I want to give this an “active class” only if it is truly the home page, i.e. <http://my-site.com/>. Very cumbersome to do this with only core Txp tags.

Last edited by jsoo (2011-01-14 21:23:46)


Code is topiary

Offline

#2 2009-07-21 18:59:54

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

Re: soo_if_frontpage: is this a section front page?

Released v 0.1.1.2, adding month and author to conditions to check against.


Code is topiary

Offline

#3 2009-09-25 01:18:54

xavoy
New Member
Registered: 2009-09-25
Posts: 2

Re: soo_if_frontpage: is this a section front page?

Thanks mate, you’ve saved me writing some messy conditionals :)

Offline

#4 2009-09-25 01:37:18

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

Re: soo_if_frontpage: is this a section front page?

No worries!


Code is topiary

Offline

#5 2009-09-25 04:59:35

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,090
Website GitHub Mastodon Twitter

Re: soo_if_frontpage: is this a section front page?

Jeff, i’ll need to start recommending this plugin. I’ve been using the glx_if for so long that it is the first which comes to mind when people are asking for such separation. I just replaced it with yours and it not only works, it also performs faster.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#6 2009-09-25 05:51:38

jstubbs
Member
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: soo_if_frontpage: is this a section front page?

Thanks Jeff, I also succumbed on one site and used it! Very useful!

Offline

#7 2009-09-25 10:31:48

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

Re: soo_if_frontpage: is this a section front page?

colak wrote:

it also performs faster.

Curious: by what measurement? Although the plugin is much smaller, having just the one tag, when it comes to the actual functions soo_if_frontpage has more code (and an additional function call) compared to (individually) glx_if_frontpage, glx_if_not_frontpage, glx_if_section_frontpage, or glx_if_not_section_frontpage. Of course it’s faster for typing being able to use <txp:else /> ;)


Code is topiary

Offline

#8 2010-03-29 12:32:18

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: soo_if_frontpage: is this a section front page?

When i open site.ru/blog/ plugin returnes TRUE. I think it should say FALSE

Just found – a little code changing made it work:

The result is:

	return parse(EvalElse($thing,
		( $section ? in_list($pretext['s'], $section) : true ) and
		( $pg ? $pretext['pg'] < 2 : true ) and
		( $pretext['s']=='default' ? true : false) and
		empty($pretext['c']) and empty($pretext['q']) and empty($pretext['author'])
		and empty($pretext['month']) and $is_article_list));

Than at section pages plugin returns false, as expected

Last edited by the_ghost (2010-03-29 14:12:45)


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#9 2010-06-22 20:59:15

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

Re: soo_if_frontpage: is this a section front page?

Victor, thanks for catching this. I managed to miss your post at the time.

Version 0.1.3 now available, fixes the bug found by Victor.


Code is topiary

Offline

#10 2010-10-07 00:30:31

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

Re: soo_if_frontpage: is this a section front page?

Version 0.1.4 released.

You can now use section="*" as a shortcut for specifying all sections (including default).

Thanks to alanfluff for the feedback.


Code is topiary

Offline

#11 2010-10-07 13:13:58

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

Re: soo_if_frontpage: is this a section front page?

Make that version 0.1.5 0.1.6. No behavioral change from 0.1.4, just a documentation update and some code cleaning.

Last edited by jsoo (2010-10-08 12:37:09)


Code is topiary

Offline

#12 2011-01-05 01:51:07

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

Re: soo_if_frontpage: is this a section front page?

Version 0.1.7 available

Documentation update only. (Thanks to admi for the suggestion.)


Code is topiary

Offline

Board footer

Powered by FluxBB