Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-03-21 02:30:12

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

Content type upgrade

URLs of the form /category/some-cat only refer to articles so you can’t get nifty category lists of images, files or links from the URL. As of r3333 there’s tentative support for category listings of other content types. There might still be a little bit of fallout and refactorisation to make it more efficient yet, but the general idea is that you can specify URLs like this:

  • /category/some-article-cat (as before)
  • /category/image/some-image-cat
  • /category/file/some-file-cat
  • /category/link/some-link-cat

The URL /category/article/some-article-cat is valid, but the core won’t output that for backwards compatibility reasons; the type identifier is omitted from such links.

<txp:category_list /> is already type-aware but now the <txp:category /> tag’s link attribute will generate a URL of the above format for the given type. The URLs are language-aware so, for example, in Swedish you would use:

  • /kategori/some-article-cat (as before)
  • /kategori/bild/some-image-cat
  • /kategori/fil/some-file-cat
  • /kategori/laenkar/some-link-cat

(or whatever — my Swedish sucks :-) Someone please update the language strings if that’s wrong!)

In order for this to work, it does rely on correctly translated (probably dumbed-down ASCII) strings for article_ctype, image_ctype, file_ctype and link_ctype being available in any given language. If there’s a better way to do this so the system still works even if a string isn’t translated, I haven’t found it yet. Send prods/answers/help this way please.

Other alterations in this changeset:

  • The <txp:page_title /> tag correctly shows the category title of the current content type, if viewing a category list page
  • <txp:if_category /> can now compare against a particular type so you can take action if on an image category list page, for example
  • Pagination support has been added to <txp:image_list />, <txp:file_download_list />, and <txp:linklist />. It uses the same paging system as articles at the moment so you can only page one type of content at a time, though $pretext['ctype'] and $thispage['ctype'] do indicate which type of content is currently being viewed/paginated

One minor annoyance is that the “page doesn’t contain an article tag” warning still prevails if you are dealing solely with different content types. So you’ll probably still have to put an article tag with pgonly="1" on the page somewhere to silence it.

If this changeset turns out to be useful, a few other related things might pop up. The first is the notion of a <txp:if_list_category> tag that takes a type attribute. That would work in the same way as <txp:if_article_category> but for other content types. So, for example, inside a <txp:linklist> form/container you could check if the current link category matches something and take action.

There are probably other things that could be done to make this more useful — I’m sure you have ideas. But if I’ve forgotten something obvious, please let me know. Of course, if I’ve overstepped the mark here or made a non-backwards-compatible goofup (it seems to be ok in my testing) I’ll back out the changes to leave TXP as it was before this evening’s meddling.

Questions / comments?

Last edited by Bloke (2010-03-21 02:32:28)


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

#2 2010-03-21 04:29:02

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

Re: Content type upgrade

Can you add a new tag, or type="content_type" to <txp:page_url />, so that we can output the currently viewed content type and hump it like dogs that we are?

Bloke wrote:

The URL /category/article/some-article-cat is valid, but the core won’t output that for backwards compatibility reasons; the type identifier is omitted from such links.

Double content? Maybe it doesn’t matter in TXP’s case.

$pretext['ctype']

Plugin template and load_order versus order. Adding one rule more to my iRuleBook.

Last edited by Gocom (2010-03-21 04:30:53)

Offline

#3 2010-03-21 07:34:53

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

Re: Content type upgrade

Gocom wrote:

Can you add a new tag, or type="content_type" to <txp:page_url />

Doesn’t <txp:page_url type="ctype" /> work?

Double content? Maybe it doesn’t matter in TXP’s case.

Shouldn’t get double content if you never link to the /category/article/some-cat form maually. TXP won’t output it so the search engines should never find out about it… ermm I thunk. If that’s not true, please let me know.


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

#4 2010-03-21 08:24:20

the_ghost
Plugin Author
From: Minsk, The Republic of Belarus
Registered: 2007-07-26
Posts: 907
Website

Re: Content type upgrade

Would there appear tags for content-linking? For example, <txp:permlink type="image" id="20" /> -> http://site.by/images/20 or something like this? Or link building would be manual?


Providing help in hacking ATM! Come to courses and don’t forget to bring us notebook and hammer! What for notebook? What a kind of hacker you are without notebok?

Offline

#5 2010-03-21 09:05:29

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

Re: Content type upgrade

the_ghost wrote:

Would there appear tags for content-linking?

I hadn’t considered that. At the moment the ctype is only populated in category lists so there are no permlink options for other content types. Incidentally, I chose ctype because it holds the category type, and the category is called c in $pretext.

Since there is no site.com/content-type/id permlink structure — due to TXP’s article-centric nature — you’d have to construct such URLs manually and trap the 404 to deliver the content you desired (or use gbp_permanent_links to fake it).


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

#6 2010-03-21 09:12:47

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

Re: Content type upgrade

Bloke wrote:

Doesn’t <txp:page_url type="ctype" /> work?

Oh snap, forgot that it can show anything from pretext.

Shouldn’t get double content if you never link to the /category/article/some-cat form maually.

Even if site author never links, other sites can. Blackhat tacktics to gain ranks among search indexes is really common.

But it really does not matter as TXP has no filter for URIs (messy works, clean works, article titles can be anything in /id/title, example.com?fake=tits works etc), but all of those can be manually resticted with robots.txt and/or redirected.

Last edited by Gocom (2010-03-21 09:14:22)

Offline

Board footer

Powered by FluxBB