Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-03-03 16:03:19

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

How TXP decides what kind of page to display?

Hello, after years of using textpattern, I’m still confused about how to structure a website and how textpattern decides which page to display. I have used gbp_permanent_links in the past, but presently, I’ve got basically one page for the entire site with a massive amount of logic in it for all the different types of page the site needs, and I realized, that’s all because I just don’t understand how txp runs. I think it would help if I understood:

—What things should be sections?
—What things should be categories?
—Is there a list anywhere of all the different types of pages txp will produce (article, article list, category, category list, etc)? or maybe it would be better to think of these as just flags instead of pages?
—When index.php receives a url, how does it decide what page to display?

Thank you for any help!

Offline

#2 2014-03-03 17:25:15

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

Re: How TXP decides what kind of page to display?

Hi kr37, have you read this article in the docs: Textpattern Semantic Model? And don’t overlook the links at the bottom of the page, they are very helpful. In particular the first two, though they are currently unavailable because the site in question is in maintenance mode…

I think most of your questions will be answered in one or more of these resources, if not don’t hesitate to post back here.

Offline

#3 2014-03-03 19:21:56

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How TXP decides what kind of page to display?

Thank you Els, those are helpful. These still leave me trying to work it out a bit:

  • In Textpattern Semantic Model, it says: Sections, as you might expect, provide the lateral structure in a website, and are often reflected by the main navigation menu links.
  • In the Tutorial by Edmonds, it says: PLEASE READ THIS NOTE: Sections relate to formatting. Sections have absolutely nothing to do with content! Do not confuse Sections with Categories.

To the user, I think the main navigation links are about content.

Suppose the site has
  1. 1) a special home page, 2) a calendar page, 3) many events pages, 4) many static ‘about’ pages.
  2. Each events page has several articles on it. Some events(articles) could be displayed on two different events pages.
  3. And suppose that among the events pages, there are ten separate pages for different types of events in one city, four separate pages for different types of events in another city, and nine more events pages for other cities.

Method A
4 Page Templates
4 Sections
Many Categories
URL: /Category/

Method B
4 Page Templates
Many Sections
Categories are not necessary
URL: /Section/

Last edited by kr37 (2014-03-03 19:23:26)

Offline

#4 2014-03-03 20:27:08

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,921
Website GitHub

Re: How TXP decides what kind of page to display?

It helps to think of sections as sectioning a site, i.e. dividing it and categories as attributes of an article.

There’s often more than one way of doing things, but for the configuration you mention, here’s one way:

Templates:

  • home page
  • calendar page
  • event page
  • static page

These are essentially four different layouts or schemes for how a page is structured. If your static pages vary greatly in their structure, consider more templates for the different kinds of pages.

Sections:

  • default (this is standard in txp and = home) – assigned to “home” template
  • calendar – assigned to template “calendar”
  • events – assigned to template “events”
  • static pages as you need them on your site, e.g. /about, /contact, /services, /how-it-works – all assigned to template “static page”

These correspond to your menu items and url structure, e.g.

/
/calendar
/events
/about
/contact
/...

Categories:

  • event type (parent category)
    • workshop
    • seminar
    • lecture
    • pecha kucha

Categories serve here as identifiers of types of an event.

Each event is an article assigned to the section “events” and the respective “event type” category. This enables you to filter your list of events by a category, e.g.
The url for an article list of just lectures would be:

www.yourdomain.com/events?c=lecture

while the url for the profile of individual event would be:

www.yourdomain.com/events/name-of-specific-event

You could either make custom fields for the city name, and probably a few more with other key event parameters – location, speaker, begin date, end date – and then simply list them with the custom fields. You can use the txp:article_custom tag to sort by a custom field if you want your events listed by city, and you can use that in combination with txp:if_different to make city headings, e.g. a heading “New York” followed by the events there, then another heading “Washington” followed by the events there.

Another approach (instead of using a custom field to hold the “city” data) would be to make a second set of categories to filter by city, e.g.:

  • event place (parent category)
    • New York
    • Washington
    • Miami
    • Boston

Here you would assign your article to the section = events, category1 = lecture (e.g. respective event type), and category2 = New York (e.g. the relevant “event place”).

The url for an article list of all events in New York would be:

www.yourdomain.com/events?c=new-york

Note I’ve shown “event type” and “event place” as parent categories with the respective categories as sub-categories thereof. You wouldn’t actually assign an article to these, only to the sub-categories, e.g. “lecture” and “New York” as shown above. The parent category is purely organisational, but it also helps you to build the UI-elements for the filters, e.g. a drop-down for event types and for event places, because you can use txp:category_list to output just the children of a parent-category.


TXP Builders – finely-crafted code, design and txp

Offline

#5 2014-03-03 20:59:22

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How TXP decides what kind of page to display?

Thank you, jakob,

I think I’ve always been trying to avoid messy urls, but maybe they just need to be messy.

Can the navigation menus refer to
www.yourdomain.com/events?c1=lecture&c2=newyork

or do I do my own trapping of the post variables:
www.yourdomain.com/events?c=lecture&city=newyork

Is it possible to do
www.yourdomain.com/events/newyork/lecture

Thank you so much for all the help.

Offline

#6 2014-03-03 21:02:32

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

Re: How TXP decides what kind of page to display?

Sections have absolutely nothing to do with content!

That’s a bit strong, but the sentiment is that a Page, affiliated to a Section along with a Stylesheet, is about presentation more than content, and that’s a pretty good (if sometimes difficult to attain 100%) goal.

Everything jakob says is rock solid in terms of options for organisation. He’s done a few huge events sites and knows the pitfalls that can bite someone embarking on this type project, so the benefit of his wisdom cannot be underestimated.

As for the last two questions you posed…

Is there a list anywhere of all the different types of pages txp will produce … When index.php receives a url, how does it decide what page to display?

There might be a definitive list of page types somewhere, but it won’t help much. Textpattern just has “list” pages (a.k.a. “landing pages” such as article list, category list, author list, search results) and “individual content” pages, which are primarily articles but can in more recent versions be single images, files, or links. Under the hood Textpattern works on what we loosely call a ‘context’ system that maps URLs to content in the database. The URL dictates whether Txp is in list or individual context/mode, and what ‘type’ of content the visitors wishes to see, then sets up a series of internal data structures populated with appropriate matching content that your Page templates can show or test to deliver to the browser.

Rather than dive into it in any more details here, I’ll refer you to an excellent introduction to context by jsoo which I heartily recommend.

If you have any more questions after swallowing that then please ask here and we’ll do our best to field them.


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 2014-03-04 00:27:24

bici
Member
From: vancouver
Registered: 2004-02-24
Posts: 2,120
Website Mastodon

Re: How TXP decides what kind of page to display?

@kr37 You might it helpful to go through this tutorial . It doesn’t take long and it helped me to better understand the Textpattern Way.


…. texted postive

Offline

#8 2014-03-04 07:21:51

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How TXP decides what kind of page to display?

Thank you, Bloke and Bici, I’ve just waded through jsoo’s document, wonderful information. It’ll take a bit to digest.

Offline

#9 2014-03-04 09:40:13

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,921
Website GitHub

Re: How TXP decides what kind of page to display?

txp’s own tags only respond to a single category, so I’ve not been able to filter by two categories at once without the help of a plugin.

The first question you could ask yourself, though, is if you actually need to filter by two categories. If, for example, your newyork category produced 7 events, of which 3 are lectures, has your user gained much by shortening the list of matches from 7 to 3. In this case the user would probably have no probably scanning all seven results. It may depend on the size of the site, e.g. if you have 150 events in new york of which 21 are lectures, it certainly does make sense to provide a two-category filter. There are also intermediate UI strategies such as making the event list sortable by type and creating a #lectures jump links at the top of the event list to take you straight to the heading for “lectures”. For this you need to create an own sort-by url parameter (there are examples of this in the forum, e.g. analog example).

Getting back to your question: there used to be chh_article_custom which did something like www.yourdomain.com/events?c1=lecture&c2=newyork but I’m not sure that that still works (also it prescribes that you use category1 and category2 uniformly). Likeweise an early version of glz_custom_fields used to allow filtering by multiple custom fields, but I think that is also no longer compatible with recent txp versions.

A couple of avenues you could explore:
  • Jeff’s soo_article_filter gives you the ability to add further criteria to article or an article_custom query. As far as I recall, it filters the results of a normal txp:article(_custom) tag by a further criteria.
  • Stef’s smd_query replaces the article_custom tag and can be used to generate your own database query based on post variables that you pass via the url. You can do some very powerful things with this but you’re not using the standard txp article method here.
  • I keep reading good things about etc_query but have not tried it yet. Maybe that can do it too.

To get clean URLS like www.yourdomain.com/events/newyork/lecture you will either need gbp_permanent_links (it’s powerful but often needs a bit of getting to grips with) or – if your query structure is quite predictable – add some new url rewrite directives to your .htaccess file. You may find you need an additional item in your url, as txp would normally resolve yourdomain.com/events/newyork as an article in section “events” with title “newyork” instead of as a list of articles in the category “newyork”. If you have an additional item in your url yourdomain.com/events/category/newyork (instead of category, you could just as easily use in or location) you’ll avoid that.


TXP Builders – finely-crafted code, design and txp

Offline

#10 2014-03-04 10:58:11

etc
Developer
Registered: 2010-11-11
Posts: 5,393
Website GitHub

Re: How TXP decides what kind of page to display?

jakob wrote #279415:

Getting back to your question: … something like www.yourdomain.com/events?c1=lecture&c2=newyork
… I keep reading good things about etc_query but have not tried it yet. Maybe that can do it too.

It can, but etc_search would be more appropriate here: create a search query (with id=1, say)

{Category1::/^@1([\w\-\%]+)$/::{*} LIKE '%$1%';Category2::/^@2([\w\-\%]+)$/::{*} LIKE '%$1%'}

and call

<txp:etc_query data="{?c1,c2}" globals="_GET">
	<txp:etc_search_results id="1" query="@1{?c1|%} @2{?c2|%}" />
</txp:etc_query>

where needed. This will be ready for pagination, native or pluginish. If preferred, etc_query can be replaced by adi_gps (or even txp:php), it serves only to retrieve url variables here, but that’s an occasion to test. :)

Last edited by etc (2014-03-04 13:41:59)

Offline

#11 2014-03-04 20:50:06

kr37
Member
From: Colorado
Registered: 2011-11-06
Posts: 28

Re: How TXP decides what kind of page to display?

Thank you, everyone, for the help so far. As usual, it seems that textpattern offers a myriad of ways to accomplish things, with pros and cons to the various methods.

So categories are about content and sections are about presentation. For most sites, I would think the URL is principally about content, not presentation. It seems like categories could logically be assigned a section, just the way articles are. Then the URL could just be about what content is requested, and txp can figure out based on that how to display it. .

Is it because categories don’t specify section that in Textpattern Semantic Model, it says:

Sections, as you might expect, provide the lateral structure in a website, and are often reflected by the main navigation menu links.

Why are sections reflected in main navigation links? Because categories can’t presently specify section.

I’m thinking about a plugin that
  1. adds a section drop-down to categories, and
  2. in pretext:
    1. if there is no section context specified(default section) but
    2. if there is category context and that category has a section defined,
      • then it sets the section context according to the category.

I think in my mind this is all coming from the wish for simple URLs that look closely tied with the hierarchy of the content, which is the hierarchy of the site. And Section doesn’t really want to be involved in the hierarchy of the site. Am I confused still?

Offline

Board footer

Powered by FluxBB