Textpattern Forum

You are not logged in. Register | Login | Help

#11 2008-05-22 17:58:54

Els
Admin
From: The Netherlands
Registered: 2004-06-06
Posts: 7,388
Website

Re: Central storage for site-wide constants: Helpful?

colak wrote:

Vote for core:)

+1 :)


<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields

Offline

#12 2008-05-23 01:16:38

hakjoon
Moderator
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,631
Website

Re: Central storage for site-wide constants: Helpful?

core :)


Shoving is the answer – pusher robot

Offline

#13 2008-05-23 08:07:44

Mary
Sock Enthusiast
From: Canada
Registered: 2004-06-27
Posts: 6,235

Re: Central storage for site-wide constants: Helpful?

One of the basics of my idea was to leave no traces in the database.

Er, are forms not in the database now?

I guess you mean no new table, right?

Last edited by Mary (2008-05-23 08:12:29)


My email address has changed recently. If you need to contact me, use the forum contact form.

Offline

#14 2008-05-23 08:54:21

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,108
Website

Re: Central storage for site-wide constants: Helpful?

Mary wrote:

I guess you mean no new table, right?

To rephrase: nothing which would require a new UI or longish explanations of how to CRUD these variables. I think that forms, tags and pages are broadly understood and readily available to a designer. Otherwise it would probably fit into (a second instance of) prefs. I’d prefer a method of creation which is for instance deployable with mcw_templates.

Last edited by wet (2008-05-23 09:09:27)

Offline

#15 2008-05-23 12:57:32

uli
Moderator
From: Cologne/Köln
Registered: 2006-08-15
Posts: 3,094

Re: Central storage for site-wide constants: Helpful?

Couldn’t this be done by giving a name attribute to a well introduced tag, <txp:text />?


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#16 2008-05-27 23:29:53

uli
Moderator
From: Cologne/Köln
Registered: 2006-08-15
Posts: 3,094

Re: Central storage for site-wide constants: Helpful?

Interesting to read where this has grown in the meantime!

Will it be also possible to use variable names already created by txp code/plugins? If so:

  • Is there a list of var names anywhere?
  • How can I display the currently used ones and their contents?

In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#17 2008-05-28 03:35:29

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Central storage for site-wide constants: Helpful?

Uli, insert <pre><txp:php>print_r($GLOBALS);</txp:php></pre> somewhere in your template.

Offline

#18 2008-05-28 04:34:54

wet
Developer
From: Lenzing, Austria
Registered: 2005-06-06
Posts: 3,108
Website

Re: Central storage for site-wide constants: Helpful?

Commited as change set 2899.

uli wrote:

How can I display the currently used ones and their contents?

<txp:variable name="humtata" value='<txp:php>global $site_slogan; echo $site_slogan;</txp:php>' />;

Last edited by wet (2008-05-28 04:39:34)

Offline

#19 2008-05-28 05:42:25

maniqui
Moderator
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 2,989
Website

Re: Central storage for site-wide constants: Helpful?

wet, your fingers are inspired…

A sci-fi feature request:

Imagine…
Imagine a future functionality (a plug-in?) on the admin side… that looks (parses) for declared <txp:variable name="varname" value="" /> on top of templates and then, somewhere in the admin interface (probably in a tab we want to make accessible for our clients… or not), it renders (automagically and on-the-fly) little form, made from a label (txp:variable name value) and a text input field (prefilled with txp:variable value value) for each txp:variable for every variable in every template.
Then, using that form, we/our-clients can rewrite the value of any variable on any template (that means, we set a new value, hit “Submit”, then TXP magic dust goes to the template, looks for the corresponding txp:variable name="name" tag and rewrites it with the new value for value.

Some ideas about this:

  • no need for storing the variable name/value on the database
  • no need to give access to template tab to our clients if, for some reason, we/they need to change the value for a variable.
  • we will be able to create some on-the-fly mechanisms for controlling template logic, and so, the HTML output

Example:

<txp:variable name="closed_for_vacation" value="no" />
<txp:variable name="display_banner" value="yes" />
// ...
// ...
<txp:if_variable name="closed_for_vacation" value="yes">
We are closed for vacations. Come back later.
<txp:else />
It's open. We are here.
</txp:if_variable>
//...
//...
<txp:if_variable name="display_banner" value="yes">
Super mega banner.
<txp:else />
No banner here.
</txp:if_variable>

Again, for those two declared variables, there is a magic parser that looks for txp:variable and creates on the fly the two label/text input fields for changing the current value to a new one.
Client changes the value, hits submit, the value is replaced on the tag (on the template).
Then, clients will be able to control the chunks of conditional code, in other words, of the output, in a new way.

Am… I… missing… something?

Last edited by maniqui (2008-05-28 05:43:16)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#20 2008-05-28 05:58:13

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Central storage for site-wide constants: Helpful?

no need for storing the variable name on the database

Well, the variables are inherently stored in the database (via forms and pages). They just lack defined records.

I think it would be easier to modify variables from an admin form if they were stored in a txp_variables table. Users can define form-modifiable ones through the admin, as in your example, or they can use them in templates like the current implementation (“inline”). The inline ones won’t be modifiable via the admin.

So closed_for_vacation would be defined and edited in an admin form, but <txp:variable name="tmp" val="foo"/> in a page wouldn’t be modifiable through the admin.

Last edited by jm (2008-05-28 05:59:11)

Offline

Board footer

Powered by FluxBB