Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-11-01 07:26:29

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Bolting textpattern on as subdirectory blog CMS

Hello,

Just thought I’d show off my effort with textpattern, which has taken me a couple of weeks and gone relatively smoothly. It’s more or less ready to go – there are a few more things I’d like to add but they’re relative complex and I suspect they’ll take me a while.

The main non-textpattern part of the site is at http://extreme-macro.co.uk/ and is a couple of hundred flatfile php files using commentics to add comments. But for the blog section I wanted something that was a bit neater than wordpress (too many included files for my liking in that package) and something that could use php. So I’ve made textpattern as consistent as I could with the rest of the site and I think it’s gone ok – the textpattern part of the site starts at http://extreme-macro.co.uk/extremist/

The biggest challenge was making it use the commentics comment store rather than textpattern – I did this so I could keep all the comments in a single database and thus also get them out by date on the sitewide right hand side includes. One nice thing I did was add custom variables to every page which allows me to add unique “Related Articles” widgets to every page. The same custom variables also let me restyle some things nicely like for example blockquotes, to be consistent with the rest of the site.

Developing with textfile has been straightforward and the package is easy to understand after getting your head into it. The community help is really beneficial and I’d especially like to thank Bloke, who has been very quick to answer hapless forum threads. The biggest challenge for me really, being brand new to it, is to find a way to wade through all the information on the forum and find plugins that are current.

In terms of moving forward, I’d like to add date based archives and find a way of integrating the “last saved date” into the same database that stores these for my php flatfile dates so that the thing on the homepage shows both blog and flatfile changes. That’s going to take much longer as I’m not that great with MySQL. I note that my office is moving to the same town as chi next month, and I might need to take chi out for a beer if I get tooooo hopelessly stuck :)

Thank you for your time,
-Johan

Last edited by ingleslenobel (2014-11-01 07:32:57)

Offline

#2 2014-11-01 23:01:48

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

Re: Bolting textpattern on as subdirectory blog CMS

Looking good. Nice match-up of styles between the sites.

Finding current plugins isn’t all that easy at the moment, and we know about it. I had plans ages (aaagggeeessss) ago to fix up our plugin repository. Made a start on it too. Then everyone started using Github. Then composer. And the old site just kinda got left to rot until someone smarter than me figured out a way to tie everything together in a manner that could be queried by people’s local installations in a more seamless manner, and wasn’t a burden on developers to maintain. Uploading plugins to multiple places just to maintain the repo seems backwards to me. Developers should be able to choose where they develop and have the repo track their plugins such that they can be searched / downloaded by first-time users and updates are offered to existing users. Still waiting for a white knight to ride up and do this.

With regards your site, date-based archives are fairly easy to achieve from a given section. It’s baked into the core and all you have to do is make sure you have a conditional in your page template that displays articles on landing pages. For example, a very basic setup for landing pages is:

<txp:if_article_list>
   <txp:article form="article_listing" />
   <txp:older>Older results</txp:older>
   <txp:newer>Newer results</txp:newer>
<txp:else />
   <txp:article />
   <txp:link_to_prev>Previous article</txp:link_to_prev>
   <txp:link_to_next>Next article</txp:link_to_next>
</txp:if_article_list>

With that kind of setup If you use the month attribute in the URL, your landing page will show articles from the given time period. Try it. Add ?month=2014 to see all articles from that year. Use ?month=2014-06 to see all articles from June 2014. You can even put a date in too to see articles from that particular day.

So the second half of the problem is how to actually list the articles in a date-based manner. If you don’t fancy rolling your own complete archive (like you’ve been exploring with Michael), you can do a lite version using one of the most underrated Textpattern tags: txp:if_different. Michael uses that in his how-to so you might have already encountered it, but it’s worth reiterating its power here for anyone else who stumbles across this thread. When you wrap your brain around it, the power this tag can deliver with some clever use of Forms is phenomenal. It’s like a mega-conditional in one tag, though it can sometimes be annoying to handle exceptions. But throw in something like smd_if or txp:if_variable too, and it’ll blow your socks off.

I won’t go into the detail of setting it up here, but if your landing page article tag is set to order your articles by descending date, inside your article / article_custom container (or Form) you could employ something as minimal as this:

<txp:if_different>
   <h2><txp:posted format="%Y" /></h2>
</txp:if_different>
<txp:if_different>
   <h3><txp:posted format="%B" /></h3>
</txp:if_different>
<txp:permlink><txp:title /></txp:permlink>
<br />

That’s untested so it might be a bit rough, but the general idea is that it only prints the stuff inside the <txp:if_different> if the content differs from last time that exact tag was encountered. So in a list of date-order articles, the logic goes:

  • Article 1.
    • First if_different block: Hmmm this article’s published in 2014. Last time I ran (which is never) this thing was empty, now it has 2014 in it. OK, that’s different, I’ll display it. So it outputs 2014 to screen.
    • Second if_different block: Hmmm, article published in November. Not seen that before, so display the tag’s contents: November.
    • Show linked title to article 1.
  • Article 2.
    • First if_different block: Hmmm 2014. Last time I ran, this item contained 2014, now this article is also published in 2014. OK, skip displaying anything here.
    • Second if_different block: Hmmm, November. Same as last time. Skip it.
    • Show linked title to article 2.
  • Article 3.
    • First if_different block: Hmmm 2014 again? OK, skip it.
    • Second if_different block: Hmmm, October. Last time it was November. That’s different. So I’ll display October.
    • Show linked title to article 3.
  • Article 42.
    • First if_different block: Hmmm published in 2013? Woah, last time was 2014. I’ll display this new content.
    • Second if_different block: Hmmm, December. Last time it was January. That’s different. So I’ll display December.
    • Show linked title to article 42.

Combining that with Textpattern’s month attribute, you could very easily wrap the <txp:posted> values in anchors which jump to URLs that would filter your landing pages by the given month/year. No plugins required.

Updating your last published date is probably fairly easy too (depending whether or not the data is in the same physical database or spread across more than one). I’m unable to advise on this unless more detail is supplied about your setup.

Hope that helps at least.


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 2014-11-02 11:00:38

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: Bolting textpattern on as subdirectory blog CMS

Ahhhhhhhh, I see. Thank you, that looks ideal for my purposes, as all I’d really like is a topnav link to a page that has a list of articles by date! I’ll get on it… thanks again for answering the hapless newbie =)

Offline

#4 2014-11-02 13:30:30

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: Bolting textpattern on as subdirectory blog CMS

Am I being dense?

I wanted to try this out so:

  • created a new section called vault, using archive template
  • made vault use form vault_listing, exactl copy of article_listing
  • all deliberately an exact copy of how articles appear under /articles/
  • vault_listing isn’t showing at all?
  • (vault_listing form has testpar outside of all if formatting so that should show)

Last edited by ingleslenobel (2014-11-02 13:33:34)

Offline

#5 2014-11-02 16:12:49

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

Re: Bolting textpattern on as subdirectory blog CMS

If you’re using the standard txp:article tag, that will list the articles in the section you are in. Your new section is called “vault” but if your articles are filed under “articles”, they won’t be listed here.

Some possible options:
  • Use the landing page of the “articles” section for your list, or
  • When articles are “archived”, assign them to the “vault” section, or
  • On your vault page, use the txp:article_custom in combination with the attribute section="articles” to make it explicitly list articles from the other section.

TXP Builders – finely-crafted code, design and txp

Offline

#6 2014-11-02 16:21:54

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: Bolting textpattern on as subdirectory blog CMS

Thanks Jakob,

I don’t really understand what you’re saying. I need to investigate your options further. Thanks again though.

Offline

#7 2014-11-02 17:27:07

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

Re: Bolting textpattern on as subdirectory blog CMS

I’ll try again:

The txp:article tag you have on your new vault section will only show you a list of articles that are saved in the vault section. Your articles are probably assigned to another section. Open up an article on the admin side and have a look at the “section” drop-down on the right-hand side. Make a mental note of the section.

If you change your tag on the vault page to be:

<txp:article_custom form="vault_listing" limit="5" section="articles" />

… you should see them. Change section="articles" to the section your articles are actually saved in.

The other alternative is to leave your code as is and manually switch over an article to the vault section after X months, or whenever you think it’s not current anymore. The problem with this is 1) you have to do it manually, and 2) you break links in search machines and elsewhere, so the first variant is probably better.


TXP Builders – finely-crafted code, design and txp

Offline

#8 2014-11-02 17:33:37

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: Bolting textpattern on as subdirectory blog CMS

Ahhhhhhhhhhhhh, I completely get it now. Thanks for taking the time to explain. Please excuse this uninformed newcomer :)

jakob wrote #285398:

I’ll try again:

The txp:article tag you have on your new vault section will only show you a list of articles that are saved in the vault section. Your articles are probably assigned to another section. Open up an article on the admin side and have a look at the “section” drop-down on the right-hand side. Make a mental note of the section.

If you change your tag on the vault page to be:

<txp:article_custom form="vault_listing" limit="5" section="articles" />...

… you should see them. Change section="articles" to the section your articles are actually saved in.

The other alternative is to leave your code as is and manually switch over an article to the vault section after X months, or whenever you think it’s not current anymore. The problem with this is 1) you have to do it manually, and 2) you break links in search machines and elsewhere, so the first variant is probably better.

p.

Offline

Board footer

Powered by FluxBB