Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-06-05 07:12:55

michele
New Member
From: Italy
Registered: 2006-02-06
Posts: 7
Website

How to know if I'm on the index

I know I can use <code><if_section name=”“></code> to know if I’m on the home, but that means also other pages and archives.
Isn’t there a quick way — without the use of PHP which would be a last resort — to know if I’m on the index?

Offline

#2 2006-06-05 07:27:58

Bastian
Plugin Author
From: Wuppertal, Germany
Registered: 2005-02-02
Posts: 376
Website

Re: How to know if I'm on the index

i use different pages for different sections.

the default-page is displayed at the homepage (index).
and other sections are displayed with other pages.

It is possible, to use the default-page only for the homepage and assign all other things (archives etc.) to other pages.

so a quick way to know that your at the index, is that you wan’t to know. :)

Offline

#3 2006-06-05 07:39:07

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

Re: How to know if I'm on the index

I know I can use <if_section name=""> to know if I’m on the home, but that means also other pages and archives.

Er, what do you mean? That only applies if you’re currently viewing the default section, i.e: the front or index of your site, it doesn’t care which page you’re using. :)

Offline

#4 2006-06-05 07:43:24

michele
New Member
From: Italy
Registered: 2006-02-06
Posts: 7
Website

Re: How to know if I'm on the index

I want to know if I’m on the very first page (i.e. / ), and not some other page (i.e. /?pg=2, /2006/01/, etc.).

Offline

#5 2006-06-05 07:48:13

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

Re: How to know if I'm on the index

…?pg=2…

Plugin: wet_if_page

..2006/01/...

What would the “first” page be for “/2006/01/”?

Offline

#6 2006-06-05 07:53:36

michele
New Member
From: Italy
Registered: 2006-02-06
Posts: 7
Website

Re: How to know if I'm on the index

The point is I want to display just one post on the index — the last post — while displaying more posts on other pages (not simply based on the page count).
I guess the easiest way, even though I think there should be a more elegant solution, is to look for the URI using PHP.

Offline

#7 2006-06-05 08:36:34

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

Re: How to know if I'm on the index

<txp:if_section name="">

	// if we're on the index, just show the latest post
	<txp:article limit="1" />

<txp:else />

	// otherwise, show last 15 posts
	<txp:article limit="15" />

</txp:if_section>

Offline

#8 2006-06-05 08:44:20

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

Re: How to know if I'm on the index

michele wrote:

I want to know if I’m on the very first page (i.e. / ), and not some other page (i.e. /?pg=2, /2006/01/, etc.).

<a href=“http://forum.textpattern.com/viewtopic.php?id=4526”>glx_if</a> plugin which allows you to specify the front page ie your default page when you click ‘view site’.

This is how i use it in my site

<code><txp:glx_if_frontpage>
<txp:output_form form=“front_page” />
<txp:else />
<txp:output_form form=“any_page” />
</txp:glx_if_frontpage></code>

Last edited by colak (2006-06-05 08:49:18)


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

Offline

#9 2006-06-05 08:54:13

michele
New Member
From: Italy
Registered: 2006-02-06
Posts: 7
Website

Re: How to know if I'm on the index

<code><txp:if_section name=”“></code>

It doesn’t work like I’d want it to: it’s not the same as an ipothetical <code><txp:if_index></code>.
It includes not only the very first page (i.e. /), but also other pages such as “?pg=x” and “/year/month/”.

And glx_if_frontpage works when “?pg=x” is specified, but doesn’t trap “/year/month/”.

Offline

#10 2006-06-05 11:22:00

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: How to know if I'm on the index

Offline

#11 2006-06-05 11:31:34

michele
New Member
From: Italy
Registered: 2006-02-06
Posts: 7
Website

Re: How to know if I'm on the index

Almost, there.

I think I’ll end up writing a very simple plugin to achieve exactly what I want.

Thanks to everyone for helping me. :)

Offline

Board footer

Powered by FluxBB