Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-06-27 16:56:16

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

arc_pref_override

arc_pref_override is a tiny little plugin that let’s you temporarily override site preferences in templates. This is useful if perhaps you want to slightly alter the global behaviour of articles (for example) in a particular section. The preference is not altered in the database, just in the template (as a result it only works for preferences used during the template rendering).

For example, say you want all articles to be shown on your site regardless of whether or not they have expired, but want to hide the expired articles from a particular article listing:-

<txp:arc_pref_override pref="publish_expired_articles" value="0">
  <txp:article limit="5" />
</txp:arc_pref_override>

Last edited by monkeyninja (2010-06-29 20:20:49)

Offline

#2 2010-06-29 10:10:00

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: arc_pref_override

Hi Andy,

This looks handy … I’ve often wondered about having different preference settings depending on where a website is hosted (I develop sites locally on my Mac & then do a backup/restore to get them on the net).

Looks like arc_pref_override in conjunction with aam_if_host might just do the trick.

Cheers,

Adi

Offline

#3 2010-06-29 17:37:17

Zanza
Plugin Author
Registered: 2005-08-18
Posts: 699
Website

Re: arc_pref_override

Andy, this looks promising for a feature I’m trying to accomplish: to have some comments unmoderated (via custom field pref , for a temporary period) being the comments on the whole site permanently moderated. I’ll give it a spin, thanks!

Offline

#4 2010-06-29 18:06:45

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: arc_pref_override

This is interesting, thanks Andy.

Two questions:

  • Could this plugin change the files/, tmp/ and plugin_cache_dir/ values?

I hate having them in the database, those vars doesn’t make any sense there in the db, and it makes would make it easier to collaborate and deploy quickly.

In dreamed TXP 6, those variables should be stored in config.php

  • Could this plugin change the value of Production Status variable?
    Similarly, this would be better if managed from some $debug variable stored in config.php
    In quick’n‘dirty pseudo code:
if $debug = true:
  prod_status = testing
else:
  prod_status = live

La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#5 2010-06-29 19:25:08

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: arc_pref_override

maniqui wrote:

Could this plugin change the files/, tmp/ and plugin_cache_dir/ values?

I hate having them in the database, those vars doesn’t make any sense there in the db, and it makes would make it easier to collaborate and deploy quickly.

In dreamed TXP 6, those variables should be stored in config.php

No, I don’t think so. Unfortunately a lot of the preferences get used/called outside of the template engine that this plugin can’t touch. However, I do agree with you that certain preferences should really be held in config.php. There are certain things that work much better when stored as code rather than in a database, particularly when working with a development and live version of a site. Deploying changes to a live site from a database can cause major problems if the site is actively in use whilst developments are being made.

Could this plugin change the value of Production Status variable?
Similarly, this would be better if managed from some $debug variable stored in config.php
In quick’n‘dirty pseudo code:

if $debug = true: prod_status = testing
else: prod_status = live

I’m not exactly sure whether it will have an affect on the production status as I am not sure at which stage this preference gets used. I would have thought it kicks in before the template rendering starts?

Offline

#6 2010-06-29 19:28:06

monkeyninja
Plugin Author
From: Sheffield, UK
Registered: 2008-10-14
Posts: 239
Website

Re: arc_pref_override

Zanza wrote:

Andy, this looks promising for a feature I’m trying to accomplish: to have some comments unmoderated (via custom field pref , for a temporary period) being the comments on the whole site permanently moderated. I’ll give it a spin, thanks!

I don’t think this is going to work for you I’m afraid. The moderation stuff gets called outside of the template rendering (as far as I am aware – I’ve got a comments plugin in the works).

Offline

#7 2010-06-29 21:16:04

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

Re: arc_pref_override

maniqui wrote:

In dreamed TXP 6, those variables should be stored in config.php

I highly disagree. Only thing that should be in the config.php is the details required for database connection and possible override definitions.

Database is used because it is database. When we put something into somewhere else, TXP loses the power of control and it makes it way harder to manage as then you need to configure the settings by yourself.

Yes, giving an override setting is reasonable, good thing actually, something that site devs can use, but preferences should not be moved out of the scope of the used DBMS.

Offline

Board footer

Powered by FluxBB