Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#13 2008-06-01 10:45:54
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Semi-persistent general storage plugin
Hi Stef,
my examples are vulnerable, yes, I thought so. And of course you have more oversight on what is possible to code, no doubt at all!
All I wanted was to set free some thoughts in a state of evolution TXP is getting into now, where it seems possible to take whole new paths and do three steps in one that couldn’t be done at all, pre-txp:var-times. Maybe this is not possible. But maybe the idea inheres something that can be made use of at a later point in time, when most of the “variable dust” has settled. That’s what I meant with the terminatory “little grain” thing.
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Semi-persistent general storage plugin
Here’s the first beta drop of smd_vars for your comfort and enjoyment. Emphasis on beta, though it’s fairly robust I think.
Install and visit the Extensions -> Variables tab. The help text is reasonably up-to-date but doesn’t have any examples yet.
I’ve had some real fun with this over the past few weeks and it’s totally mad what you can do with it for such a simple concept. It’ll really rock when 4.0.7 rolls in because the new tag parser and <txp:variable />
tag could make this rather useful for storing ad-hoc data across pages and testing it with smd_if.
I’m most interested in your experiences with it and what you think should be improved before this is unleashed on the masses. I would also value security feedback on whether there are too many holes in it to be of any practical use (patches welcome). And Uli, if you can use this to make some form-based queries up and show them off to the world it’d be most totally excellent and bodacious :-)
Download v0.1 | compressed | Requires an update to smd_lib v0.33
Go get variabling…
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
#15 2008-06-07 10:36:24
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,306
Re: Semi-persistent general storage plugin
WOW! Here it is? So soon!?
Thanks for all your efforts and for what this will make possible, Stef! Awesome!!
Show off my form-based queries? Audacious! Looks like I’ve got some homework to do, now! :)
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
Re: Semi-persistent general storage plugin
Update to v0.11 | compressed.
Adds the ability to smd_var_put multiple vars with the same expiry in at once. Just comma-separate them in the name
and value
parameters.
You can also now defer replacement of ?
field names to smd_var_get by specifying get_vals_now="0"
. It defaults to ‘1’ which means this:
<txp:smd_var_put name="v1, v2, v3" value="1st, 2nd has the ?url_title in it, 3rd" expiry="@20m" />
would insert 3 variables v1, v2, and v3 that all expire in 20 minutes. The 2nd one might be stored as “2nd has the my-first-post in it”. Contrast that with the same tag that sets get_vals_now="0"
. The 2nd variable would then contain “2nd has the ?url_title in it” verbatim. When you subsequently do an smd_var_get, the ?url_title
will be replaced at that time.
I have also removed the delete
attribute from smd_var_put. Instead you can now specify an action
:
replace
(default) overwrites any existing variable’s valueappend
adds the new value to the end of any existing valueprepend
adds the new value to the beginning of any existing valuedelete
removes the variable the same as thedelete
attribute used to
See how you get on with 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
Re: Semi-persistent general storage plugin
Ooops, update to v0.12 | compressed which fixes the admin side to allow empty values, like the docs say it does!
Thanks to uli for spotting that.
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
Re: Semi-persistent general storage plugin
Bloke wrote:
There’s nothing to stop you setting up a system where the ‘name’ is, for example, “favarticle_zanza” (remember you can create these things on the fly so under TXP 4.0.7 you have the full range of TXP tags with which to grab stuff) and the ‘value’ is whatever article they have indicated they prefer. (..)
I still think cookies are perhaps the “correct” way to go about this, but there’s absolutely nothing to stop you using smd_vars to do it if you prefer. Subject to local data retention laws, etc (e.g. Germany).
Wow. Sorry for the delay in replying, too much things to mumble about for non-english speaker… :) I just wanted to say that you’re doing an exciting, excellent job, I’m looking forward to play with it, just need some time and maybe the SVN TXP version… thanks a lot!
Z-
Offline
Re: Semi-persistent general storage plugin
Zanza wrote:
I’m looking forward to play with it, just need some time and maybe the SVN TXP version… thanks a lot!
You’re welcome, and yes I think this combined with smd_query will be a good test for the new parser :-)
BTW, there’s a bug that uli spotted in the current version: you cannot delete the first item in the list for some obscure reason. The correct code is put on the page but it doesn’t wrap the delete <form>
round the ‘x’ button in the first row. Totally screwy, but I think it’s to do with validation. I’ve uncovered about 50 validation issues (tut-tut, Stef) and fixed all but one of them in my dev version.
Once I have the page validating I can begin to track down what’s causing it. In the meantime if you want to delete the first item in the list, re-order the table by some other column and use a delete button in another row!
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
#20 2008-06-11 12:55:31
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Semi-persistent general storage plugin
Anyone give me a simple but and useful example of how this could be used please – it’s over my head at the moment.
Best wishes
Lee
Offline
Re: Semi-persistent general storage plugin
lee wrote:
Anyone give me a simple but and useful example of how this could be used please
Store some user-submitted info from one page and retrieve it on a later page; for example, a wizard. Break a form up over a few pages instead of having one big form. Store the results in smd_vars as each page is submitted and then — at the end when the user clicks “I’m happy, do it” — retrieve all the info stored so far and do something with it.
You could either choose to have the variables expire after a certain time (say, 10 minutes) so if the form isn’t completed within the alloted time, the vars become useless. Or keep them so if the user doesn’t complete the form staright away they can come back to it later.
EDIT: there will probably be some new convenience features coming soon to allow you to store related temporary variables and retrieve them all instead of having to list them explicitly. If I can get my head round it, that is.
Last edited by Bloke (2008-06-11 13:14:05)
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
#22 2008-06-11 13:23:23
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Semi-persistent general storage plugin
So for example if I were building an estate agent site, like I am, there could be a remember this property button on each property page and then a view previously viewed properties page where they could be a list of these properties.
Or another example could be like on Amazon where in the side bar you’re given links to previously viewed products.
Could this be done?
Thanks
Lee
Offline
Re: Semi-persistent general storage plugin
lee wrote:
So for example if I were building an estate agent site, like I am, there could be a remember this property button on each property page and then a view previously viewed properties page where they could be a list of these properties.
Exactly. It’s like cookies, but more permanent. The thing you have to remember with this (at the moment, until I add temporary sessions) is that the variables all have to be named. The names can vary of course based on info in the current article (a custom field for example, or something off the URL line) but you must be able to refer to the variables by name later in order to read their values.
So, for example, you could not hard-code on your page a variable called proplist
if you intend to build a list of properties a visitor has flagged for later comparison. Because if two visitors were viewing the same page they’d fight over the variable name! When I implement temporary sessions there’ll be the concept of a ‘prefix’ (for want of a better word) so that all variables from a particular session/browser are kept together and treated as a group if you wish.
Or another example could be like on Amazon where in the side bar you’re given links to previously viewed products.
Yes. This one would benefit from using ign_password_protect or mem_moderation so the functionality is unlocked when a user has an account and is logged in. Then you can simply store variables that are prefixed with that user’s login name so they can be easily distinguished.
The plugin’s quite raw at the moment in terms of functionality but it’ll get some serious nitro over the coming weeks when my head’s stopped spinning enough to decide the best direction to take this. Also works best under an SVN copy of TXP so you have the new parser and <txp:variable />
to play with too :-)
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
#24 2008-06-11 13:44:49
- lee
- Member
- From: Normandy, France
- Registered: 2004-06-17
- Posts: 831
Re: Semi-persistent general storage plugin
Thanks Stef, I’ll have a play and se what I can do with it. I’m in Cov next month (I think) if you fancy a meetup/beer let me know.
Cheers
Lee
Offline