? Earlier 2 items total Later ?

On this page:?

Testing if this is NOT a category listing

The new releases of textpattern tend to use the new "yoursite.com/category/ZZZ" url format for category listing links. Which means that those category-filtered archives use the "default" template for formatting & so forth.

To handle this on the front page, you need to be able to test if the current view IS a category search, and you also need to test if this ISN't a category search (to display normal front-page content). To do this I had to modify the glx_if plugin - very easy really.

In Textpattern, go to admin > plugins, and click the "edit" link for glx_if. Add the following function anywhere it would seem to fit:

function glx_if_not_category_list($atts, $thing)
{
        global $pretext, $is_article_list;
        return (empty($pretext["c"]) && $is_article_list == true) ? parse($thing) : "";
}


A use for this is shown in this snippet.

Low-Overhead Archives By Month

You used to have to use rss_suparchive to get an archive of articles broken out by month, but this plugin produces an ungodly number of db queries when dealing with large archives (e.g., hundreds or thousands of articles).

Textpattern 4.0.2 allows you to get the same effect using the good ol' tag, which uses a LOT FEWER database queries.

You can see this in action at Not Far North.

First, you need the glx_if plugin installed.

put this in your "article" page template:


   

Archives



If you were attentive, you see that we also need an article_archive form. Create that form and put this in it:


  



Now, "yoursite.com/article" will display a list of articles broken out by month, and "yoursite.com/article/2/helloworld" will display only that article using the "default" form.

To handle category listings, install the upm_category_title plugin and add this to your front page ("default") template:


   

Articles in

View all articles



Note that using the above bit of code requires you to modify the glx_if plugin a bit - more about that in another snippet (it's really easy).

? Earlier 2 items total Later ?