Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-10-18 04:19:53

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 49

Rerouting searches & individual articles to section landing page

I’m sure that this has been discussed somewhere but I’m probably using the wrong search terms. Sometimes I need to have a section landing/list page display all the content of that section, usually in a series of panels down a long page, or columns across the page. I don’t want the individual articles to display at all.

I have used all manner of messy template tricks to handle this in the past. But people can still get to these individual article urls via the search (and I want to keep this content searchable). I’d like anyone arriving at these articles to be redirected seamlessly to the section landing page. Methods I’ve played with:

  • HTACCESS: everything I try in htaccess seems to fail (rewriterule, redirect etc)- I assume due to the TXP rewrite rules and url patterns.
  • ON PAGE REDIRECTS: use txp:if_individual_article for that section (or override form) to isolate these visitors and then send them on to the landing page using some sort of on page redirect (php,js,html).
  • WP GUTENBERGESQUE: jamming all content into a single bloated article which I make the landing page and use separators (eg “#split#”) and some jquery to split it into panels. Easily busted by client.
  • CUSTOM FIELDS: setting up custom fields for a landing page article to accommodate the multiple body fields required. Inflexible and seems over the top.
  • FORMS: use forms instead of articles to output content to the list page. I have used this for contact page panels. Would rather not let clients near forms, and forms only support plain text, and can’t be searched.
  • DUPLICATE CONTENT: using article_custom, set up the individual articles to appear identical to the list page. The content is duplicated and the meta tags get rather messy.

Here’s an example:
https://example.com/submissions
is a complete landing page with no links to the section’s inner articles. It displays all the section’s content.

https://example.com/submissions/status
https://example.com/submissions/guides
https://example.com/submissions/seminars
https://example.com/submissions/something-client-adds

These are all short articles that are each a distinct panel on the landing page. I need their content to be searchable, but I don’t want people visiting the individual articles.

Any advice would be much appreciated.

Last edited by peterj (2020-10-18 04:20:35)

Offline

#2 2020-10-18 04:28:15

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,281
Website

Re: Rerouting searches & individual articles to section landing page

Hi peter,

I am using this in the search_results form. The problem is something-client-adds as you will have no control over that.

You can of course create a pageless section for those articles, which I admit I am yet to experiment with.


Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#3 2020-10-18 07:32:49

zero
Member
From: Lancashire
Registered: 2004-04-19
Posts: 1,367
Website

Re: Rerouting searches & individual articles to section landing page

Pageless sections. I used them for this one-page theme


Wondrous Healing Wondrous ways to a healthy old age
Safe Reiki Harmless natural healing.
Gud One Blog

Offline

#4 2020-10-18 09:38:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,775
Website

Re: Rerouting searches & individual articles to section landing page

Pageless sections will definitely work, and would be my preferred route. You will need to do some trickery to make them searchable and return the correct resources, however.

The trouble is, the default search form will list the content where it’s found and will add a permlink to the individual article. But following that link (to the pageless section) will fail because there’s no template.

So you’ll need to catch this. Options include:

  • use .htaccess rules on such ‘individual article’ pages to bounce 404s back to the landing page.
  • use <txp:if_status> (possibly in conjunction with <txp:page_url> or <txp:if_request>) to detect 404s and refresh the page back to the landing page.
  • Alter your search form. If the search term matches an article that happens to be in a pageless section, change the permlink to point to the landing page instead.

Using a good naming convention will help wonders here. e.g if the ‘real’ section that visitors see is called ‘submissions’ then I’d make your ‘pageless’ content sit in a section named ‘submissions-content’. That way, if any search results land there, you can strip off the ‘-content’ and know that’s your landing page.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2020-10-18 13:39:22

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 49

Re: Rerouting searches & individual articles to section landing page

Thanks all! Pageless sections! Wow! Have it working lovely now.

What I ended up doing:

/submissions is now a single article in a “site” section used for other bitsy articles like the Privacy Policy. This section uses the /title url pattern. This seemed better than having a /submissions/ section as it uses individual article meta tags, and it means there are not two similarly named sections to confuse the client. I did need to mangle the menu’s section list a bit to show the article.

I made a new section /submissions-articles/ which is pageless(!). The section’s title is just “Submissions”.

The “submissions” article has an override form to display the content from the submissions-articles section.

Search results in this section are redirected in htaccess using
RedirectMatch 301 "^/submissions-articles/.*" "/submissions"

Last edited by peterj (Yesterday 00:20:38)

Offline

#6 2020-10-18 18:12:06

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,775
Website

Re: Rerouting searches & individual articles to section landing page

peterj wrote #326468:

/submissions is now a single article in a “site” section used for other bitsy articles like the Privacy Policy. This section uses the /title url pattern.

Clever!

The “submissions” article has an override form to display the content from the submission-articles section.

Even cleverer! I like this. Gonna steal it.

Glad you got it working, and pageless sections came to the rescue.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#7 Yesterday 03:07:31

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 8,281
Website

Re: Rerouting searches & individual articles to section landing page

peterj wrote #326468:

Search results in this section are redirected in htaccess using
RedirectMatch 301 "^/submissions-articles/.*" "/submissions"

You may not need this. In your search results form you can use

<txp:if_article_section name="submissions-articles">
<p><a href="<txp:site_url />submissions">Submissions</a></p>
<p class="entry-summary"><txp:search_result_excerpt /></p>
<txp:else />
your search results code here.
</txp:if_article_section>

Yiannis
——————————
neme.org | hblack.net | LABS | State Machines | NeMe @ github | Covid-19; a resource
I do my best editing after I click on the submit button.

Offline

#8 Yesterday 03:28:49

peterj
Member
From: Melbourne, Australia
Registered: 2005-06-02
Posts: 49

Re: Rerouting searches & individual articles to section landing page

Thanks Yiannis. Yes I guess that is a better solution as the hidden article’s title and hidden section’s slug won’t be exposed on the search results page.

Offline

#9 Yesterday 04:27:26

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 2,139
Website

Re: Rerouting searches & individual articles to section landing page

If you play it nicely, I think you should be able to link directly to the article on the submissions page.

On your submissions page template, you add an ID to the headline for each article, e.g. <h2 id="a<txp:article_id /> (you need to add an alphabetical prefix as HTML ID cannot start with a digit; use whatever you want of course).

Then for your search result template, you add to the code provided by Yiannis: <a href="<txp:site_url />submissions/#a<txp:article_id />">

(untested but i’ve used something similar in a different context)


Where is that emoji for a solar powered submarine when you need it ?

Offline

Board footer

Powered by FluxBB