Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-06-08 11:32:10

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 581

Fake Subsections

After searching the forum and reading various threads I found there isn’t an easy way to use subsections within Textpattern.

I’m in the process of drawing up a structure plan for a new website I’m to start work on next month. The site map is set in stone so I don’t have a lot of flexibility regarding it. Would it be possible to get some advise / pick the brains of the fine people here regarding the best way to structure the site. I have some ideas about trying to fake this with Sections, Article Titles and Categories but always find it helps to get second opinions in case I missed something obvious.

As an example one of the sections of the website has four levels. The Senior School section splits off into 1st – 2nd Years and 3rd – 5th Years. Both of which then splits off into an About us page for that area of the school. Within the About us page are links to various other pages. Although these pages have the same headings the content will be different.

Senior School

-- 1st - 2nd Years
---- About Us
------- Ethos
-------- Panoramic Views
------- Academic Results
------- HM Welcome letter
------- Staff List

-- 3rd - 5th Years
---- About Us
------- Ethos
------- Panoramic Views
------- Academic Results
------- HM Welcome letter
------- Staff List

Many thanks.

Offline

#2 2011-06-08 11:39:46

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,945
Website GitHub

Re: Fake Subsections

I’d be tempted to go with some gbp_permanent_links voodoo and map your subsections to real TXP sections/articles.

I’m not very skilled with the plugin though so you might have to play with it first on a test site and then ask questions on the plugin’s thread to summon the permlink magicians.


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

#3 2011-06-08 13:52:24

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: Fake Subsections

I agree with Stef. gbp_permantent_links works, but it all depends on how you want the design of section/subsection landing pages. You may need some conditional in page templates that make things not easy. In my experience for subsection you may also use custom fields together with gpb_p_l, but sometimes the plugin is buggy (or the logic behind it is not sound). I don’t have a site online to prove this, because it has been in development for a year or so, but in this time I had the chance to find and solve some not so obvious bug/odd behavior. And had the time to forget the details about them. :)

Bottom line: for my experience, I’d stay with section/categories/title if that’s viable. Far easier. But other options do exist, if that doesn’t fit.

Plus, keep site structure as flat as possible is good practice, but I know that that may not be an option…

Offline

#4 2011-06-08 14:17:41

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 581

Re: Fake Subsections

Thank you both.

I’ve been looking at gbp_permantent_links and trying to work out how it all fits together. While testing it on a clean install I’ve hit my first snag. For this project I have to develop on an IIS server but deploy to Apache. It appears that gbp_permantent_links doesn’t play nice with messy URLS, which is only to be expected I guess.

Now if I could only find an easy way to get clean URLs working in IIS

Zanza: I’d love to keep the structure as flat as possible. Unfortunately my boss has handed me a completely mapped out sitemap to work from. My original thought was to see what I could do with section/categories/title. I realised though that I’d end up with dozens of categories for each section of the site, so far I’ve counted nearly 20 sections.

Offline

#5 2011-06-09 07:08:38

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Fake Subsections

It’s sometimes a bit unpredictable, but it’s very possible to make pseudo-subsections using gbp_permanent_links.

Maniqui recently flagged up a little-used feature of gbp_permanent_links which allows you to point each type of URL to a distinct page template, to avoid a nest of conditionals. He’s come up with some neat ways to use <txp:output_form /> and <txp:yield /> to make the <txp:if_section /> logic in globally used forms manageable too. Hopefully there’ll be a write-up about it soon.

A final trick is to use the admin-side functionality of adi_menu to make the Section drop down in the Write tab mimic the ‘subsection’ hierarchy.

That said, looking again at your IA, this approach might not be suitable. Given that your ‘subsections’ have common names maybe categories are more appropriate.

Offline

#6 2011-06-09 08:50:54

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 581

Re: Fake Subsections

Interesting I shall have to investigate. I’m rather glad I gave myself a month to plan the sites structure and blueprint before I start coding.

I’m thinking out loud, here are some of the thoughts I had regarding using section / article / category URLs were:

example.com/about-us/staff-list/?c=1st-2nd-year

example.com/senior-school/1st-2nd-year-staff-list/?c=about-us

example.com/about-us/1st-2nd-year-staff-list/?c=senior-school

The main problem is that I don’t want to be drowning in sections and categories. I’d like the website to be as simple as possible to update. Also I’m not sure how SEO friendly it would be having URLs displayed in this manner. In an ideal world I’d have a URL that looked like this:

example.com/senior-school/1st-2nd-years/about-us/staff-list

Last edited by Algaris (2011-06-09 09:35:54)

Offline

#7 2011-06-09 09:03:03

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Fake Subsections

might you also have these?

example.com/junior-school/1st-2nd-years/about-us/staff-list
example.com/another-type-of-school/1st-2nd-years/about-us/staff-list

Offline

#8 2011-06-09 09:06:24

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 581

Re: Fake Subsections

Yes that’s true there is the Junior School and the Sixth Form which will use the same layout, but the way the site map has been structured it’s only the Senior School that is broken up into 1st-2nd and 3rd-5th years. So it would be

example.com/junior-school/about-us/staff-list
example.com/6th-form/about-us/staff-list

Offline

#9 2011-06-09 09:59:12

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Fake Subsections

Fun. I wish you luck! Honestly, I’m not 100% sure if it’s doable in exactly the way you want it. There’s always a way with Txp, though it will take a fair amount of jiggery pokery.

Seems obvious that the senior-school component should be <txp:section />.

Then you can use bot_write_tab_customise to show/hide the control for the 1st-2nd-years component accordingly.

That component could be handled with either categories or a glz_custom_fields-powered select list. Categories will probably make page logic simpler.

To keep the categories to a minimum I’d got with <txp:title /> for the final staff-list component. You’ll get the ‘multiple articles with same url-title’ warning in Write tab, but should be no real problem there as long as your gbp_permanent_links rules are in control.

In your example URL the ‘About us’ part is consistent and could be ‘implied’ rather than needing to define it in Txp. Let me explain…

Do you need to publish specific, authored, content to each of these pages?

-- 1st - 2nd Years
---- About Us

Assuming so, you could use a single article (probably a Sticky one, or using a custom field to disambiguate from other articles in that section) to bridge the two, using glz_custom_fields text inputs and textareas

Create a rule in gbp_permanent_links (localised to the senior-school section) with a Plain text component (/<txp:section />/<txp:category1 />/text) where text=“about-us” and in the Destination set of controls for that rule, redirect it to a specific page template, to keep separation from the output between the two views of the same article. So, these two URLs would output different elements of the same article.

example.com/senior-school/1st-2nd-years/
example.com/<txp:section />/<txp:category1 />
and
example.com/senior-school/1st-2nd-years/about-us/
example.com/<txp:section />/<txp:category1 />/text

Then, for subsequent pages I’d think you’d save a lot of hassle if you were prepared to flatten the URLs slightly (without flattening the perceived hierarchy which you could reinforce in a crumbtrail or navigation structure). I’m not sure what SEO juice you want/need for a school site, but I’m sure fewer components in the url is a healthy thing generally speaking. Dropping the ‘about us’ bit is unlikely to have any significant effect on ranking.

eg.
example.com/senior-school/1st-2nd-years/staff-list
instead of
example.com/senior-school/1st-2nd-years/about-us/staff-list

So, the key trick with gbp_permanent_links would be to make it understand the difference between these two types of URL

example.com/senior-school/1st-2nd-years/about-us/
as example.com/<txp:section />/<txp:category1 />/text/
and
example.com/senior-school/1st-2nd-years/staff-list
as example.com/<txp:section />/<txp:category1 />/<txp:title />

It would need some trickery with the precedence value, or maybe a slightly different approach altogether (like forget the example.com/<txp:section />/<txp:category1 />/text/ rule so that both URLs used the same template and then play some logic games in the template (<txp:if_individual_article /> or flipping it around and testing the URL for about-us).

If that works you should end up with a relatively simple Write tab with few categories or sections.

Offline

#10 2011-06-09 10:07:46

Algaris
Member
From: England
Registered: 2006-01-27
Posts: 581

Re: Fake Subsections

— edit 1 —
pieman I haven’t had chance to read your post yet, I was in the process of typing this when you posted. I’ll read what you had to say before making any firm decisions.

— edit 2 —
pieman thank you so much for your post. I’ll have an experiment with your advice to see what I can come up with. If I can get this work I’ll gladly go down this route.

———————

I’m thinking for my own sanity and to try and keep things as simple as possible I’ll go down the following route:

example.com/senior-school/1st-2nd-year-staff-list/?c=about
example.com/senior-school/3rd-5th-year-staff-list/?c=about
example.com/junior-school/junior-staff-list/?c=about
example.com/junior-school/6th-form-staff-list/?c=about

I’ll make sure to look at the other methods mentioned as I’m still in the planning stages. If any of them happen to allow me to produce cleaner looking URLs then I might change my mind.

Last edited by Algaris (2011-06-09 10:22:54)

Offline

#11 2011-06-09 15:43:24

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Re: Fake Subsections

I know I would flatten things out here. I dislike using categories at this point because I haven’t found a way to make category selection compulsory for clients who are editing the site. Then it’s just one more thing to remember. But nobody seems to complain about URL structure as long as the actual (superficial) website navigation has the right amount of depth.

So…following with interest!

Offline

#12 2011-06-09 15:52:31

pieman
Member
From: Bristol, UK
Registered: 2005-09-22
Posts: 491
Website

Re: Fake Subsections

maruchan wrote:

I dislike using categories at this point because I haven’t found a way to make category selection compulsory for clients who are editing the site.

I shy away from them for similar reasons. Although that problem isn’t unique to this scenario.

I guess it wouldn’t be so hard to add some jQuery validation via the custom scripts field of bot_write_tab_customise. Though that adds another hoop to jump through to get the desired results.

Offline

Board footer

Powered by FluxBB