Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-04-07 05:26:33

michael_climactic
Member
Registered: 2007-01-19
Posts: 10

Link Article Back To Its Page Within Article List

Hello,

I’m working on a product gallery for a clothing site, one product per article. I’m using:

1. txp:article (and txp:article_image w/thumbnails turned on) to display a list of 8 thumbnails per page, each thumbnail linked to its individual article. The article list is sorted by Posted, asc.

2. txp:older and txp:newer so people can cycle through the pages of the gallery.

3. txp:link_to_prev and txp:link_to_next inside the individual article form so people can cycle from individual product to individual product without going back to the gallery.

That’s all working swimmingly. I would like, however, for each individual product article to contain a link back to the page within the article list where that product “lives”.

For example, product X is displayed as article 12 within my article list, so it’s on page 2 of that list. I want its article form to contain

(product description)
(link to previous product) | (link to next product)
(link to /section_name/?pg=2)

Now, I’ve thought about plugging a page number into a custom field and then using txp:if_custom_field in the article form to generate a link back to the appropriate page.

For example: product X article thumbnail displays on page 2 of the article list, so I plug “2” into a custom field named “page”, and then insert the following into the article form:

<txp:if_custom_field name="page">
<a href="/<txp:section />/?pg=<txp:custom_field name="page" />">Back To The Gallery</a>
</txp:if_custom_field>

But that feels like a kludge. Can anyone suggest a more elegant way to achieve this behavior? Is there any way for an individual article to “know” which page in an article list it belongs to? I’ve looked at some gallery plugins but I wasn’t sure if they would let me link to articles (instead of just images). Some of the navigation plugins have cool ways to display article page links, but seem only to work within the article list.

Thanks in advance for your help, apologies in advance for any faux pas, crushing naivete, etc.

Last edited by michael_climactic (2007-04-07 05:28:10)

Offline

#2 2007-04-07 18:42:54

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

Re: Link Article Back To Its Page Within Article List

No, it is not really possible because it will be on a different page depending upon sort, limit*/[*pageby] and how many articles appear before and after it.

Your solution is indeed “kludgy” because it means you will have to update a few articles every time you add a new one or when you decide to change the attributes I mentioned above.

One possibility is to fake it with PHP using a cookie and/or a referrer check.

Offline

#3 2007-04-07 22:40:35

michael_climactic
Member
Registered: 2007-01-19
Posts: 10

Re: Link Article Back To Its Page Within Article List

Thank you for the response and advice.

Offline

Board footer

Powered by FluxBB