Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-06-27 11:19:23

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Help me think: Why does txp:article kill the category attribute?

I’m trying to find the reason for some very old code, and I’m stuck.

You may try to put this into a page:

<txp:article category="meaningful-labor" />

This is in vain: Textpattern ignores the category attribute and substitutes it with a value from the URL (http://example.com/?c=hope-for-the-future) when your page is visited, and it even erases the category completely when the URL supplies no category at all. This also applies to “author” and “excerpted”.

I’m trying to find a reason for this behaviour.

What can possibly go wrong if Textpattern uses the value from the category attribute at any occasion even if the page URL contains a ?c=somecategory bit?

Wouldn’t it be desirable that the site builder has a way of specifying an explicit category?

Offline

#2 2012-06-27 11:33:32

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

Re: Help me think: Why does txp:article kill the category attribute?

Presumably it’s to preserve the context-sensitive nature of <txp:article> and justify <txp:article_custom>‘s existence. But since:

  1. the two tags are now pretty much handled by the same code
  2. the sort order can now controlled better (w00t!)
  3. tags-in-attributes are available

I can’t see any sense in not allowing <txp:article> from having some overridable options that were hitherto only available in the non-paging-aware <txp:article_custom> realm. As long as it still retains its context-sensitivity if no attributes are supplied to override it, as you say, what could go wrong?

Last edited by Bloke (2012-06-27 11:35:07)


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 2012-06-27 11:42:16

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Help me think: Why does txp:article kill the category attribute?

<txp:article /> has never supported attributes as section, author or category as far as I know. Those attributes and code-bits are presents only because these functions has been shared by two tags, including <txp:article_custom/>. On <txp:article /> those haven’t applied as <txp:article /> has by design been context-sensitive, only treating content requested.

If the tag listened to those attributes, it would interfere with displaying individual articles too, unless the attributes are ignored in such context, and overridden by the article’s data / requested data. Limiting factors include that you can’t really use multiple instance of <txp:article /> on a single page either. The first instance decides pagination and article count.

Offline

#4 2012-06-27 11:44:13

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Help me think: Why does txp:article kill the category attribute?

To clarify: I’m talking about article lists, not individual articles.

Offline

#5 2012-06-27 11:48:22

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Help me think: Why does txp:article kill the category attribute?

wet wrote:

To clarify: I’m talking about article lists, not individual articles.

To whom? If a page has a following tag:

<txp:article category="categoryname" />

And individual article is requested which is not in that category, what will the visitor see? A 404 error page? Empty page without any content? Or is the attribute overridden?

If an empty page is displayed, how will user check and see that the article isn’t meeting the criteria? Knowing that would be mandatory to displaying error pages when content isn’t present. If a page is displayed w/o the article visible, what will individual article tags outside the <txp:article /> block do? Display the content anyways?

On list pages what will happen when you have two instances of <txp:article />. As this:

<txp:article />
<txp:article category="categoryname" />

What will happen when you change pages? What will happen when you run out of pages on the second tag’s filtered list? Will be a 404 error page displayed?

Last edited by Gocom (2012-06-27 11:56:22)

Offline

#6 2012-06-27 12:08:21

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Help me think: Why does txp:article kill the category attribute?

Good points.

Nevertheless I’d like to return to the original puzzle: What can possibly go wrong if we do not override explicit attributes from URL vars in article lists?

Offline

#7 2012-06-27 12:16:17

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Help me think: Why does txp:article kill the category attribute?

wet wrote:

Nevertheless I’d like to return to the original puzzle: What can possibly go wrong if we do not override explicit attributes from URL vars in article lists?

Above will prove problematic, but sure you can do it. It can work just fine and doesn’t break the list itself. You then just gotta make it very clear that all instances of <txp:article /> need to have the exact same attributes (there the likes as offset and limit).

There are those individual tags as page_title, category and likes that will display the category name from the URL even when <txp:article/> doesn’t listen it. <txp:page_title /> says articles are about Windows (as in URL) while the articles read about iOS.

Last edited by Gocom (2012-06-27 12:20:27)

Offline

Board footer

Powered by FluxBB