Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#37 2008-06-12 10:38:03

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

Re: Semi-persistent general storage plugin

lee wrote:

I’m using <txp:article_custom form=“property_at_a_glance” id=”<txp:smd_var_get name=“id”/>” /> but it’s returning all articles.

  1. Is your smd_var named id?
  2. Do you have asy_wondertag to wrap the article_custom with? (TXP 4.0.6 and lower)
  3. That code is on a page right, not a form or in an article? If it’s in either of the latter two you’ll get a circular reference warning

EDIT: Uli beat me to #1 :-)

Last edited by Bloke (2008-06-12 10:39:28)


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

#38 2008-06-12 10:45:34

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: Semi-persistent general storage plugin

I’m missing the wonder tag. Could I use http://forum.textpattern.com/viewtopic.php?id=26942 instead?

Thanks for the help Bloke.

Offline

#39 2008-06-12 10:48:13

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

Re: Semi-persistent general storage plugin

lee wrote:

Could I use http://forum.textpattern.com/viewtopic.php?id=26942 instead?

Oh yes :-)

Please let me know how you get on if you go with SVN becasue I’ve not had a chance to test it yet, I’m still running a stock 4.0.6 on my test server.


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

#40 2008-06-12 10:55:20

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: Semi-persistent general storage plugin

I tried it and got this at the top of all admin pages:

Warning: Unknown column ‘order’ in ‘order clause’ select name, code, version from txp_plugin where status = 1 and type=‘1’ order by `order` in /users/home/site/domains/auvergnepropertyshop.com/web/public/textpattern/lib/txplib_db.php on line 117

Offline

#41 2008-06-12 11:06:05

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

Re: Semi-persistent general storage plugin

lee wrote:

Warning: Unknown column ‘order’ in ‘order clause’ [snip]

Not me, guv :-) The ‘`order`’ table is a new one to do with plugin load order. I guess your upgrade to the latest SVN didn’t complete fully and didn’t update the plugins table. You got the entire latest version, right, installed it and logged out/in again?

Last edited by Bloke (2008-06-12 11:07:01)


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

#42 2008-06-12 11:22:05

lee
Member
From: Normandy, France
Registered: 2004-06-17
Posts: 831

Re: Semi-persistent general storage plugin

I took a short cut and just installed the 2 files needed, so that’s probably why I get the error. I’ll stick with the wonder tag.

Thanks again
Lee

Offline

#43 2009-11-19 03:23:23

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: Semi-persistent general storage plugin

Thanks for this Bloke. Your plugins have changed everything for me beyond words. In a good way I think. :) Need to get out soon.

I’ve been spending a while experimenting/trying to learn some various PHP stuff – to find ways to keep sessions. Glad I found this. Wonder why this thread hasn’t been been posted to since 4.2 came along. Has something else replaced it’s purpose?

Anyway, what I’m doing with it is incomplete:

I’m running the following:

<txp:smd_var_put name="<txp:rvm_privileged_user type="name" />_pubdate" value="<txp:variable name="pubdate" />" />

I’m setting the pubdate variable by POST which then when ran in the preceding code here successfully creates that user-unique variable and assign it’s value. I almost jumped out of my pants! It worked. Problem is that when the page is loaded again for some other reason the preceding code is ran again and sets the value to nothing. Obviously.

My Situation: So in essence I have temporary vars getting trashed which is ok. I just need to convert them to ‘session’ vars (pre-pending the username) and keep them without overwriting them.

Question: Is there some way to ‘declare’ these variables on a conditional bases so that continued page loads don’t overwrite them? Some other POST, GET method? The ability to run smd_var_put in a external form?

It must be something simple or is this the edge of the universe?

Thanks. I hope there are some subscribers here.

Last edited by whaleen (2009-11-19 08:51:11)


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#44 2009-11-19 05:39:03

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: Semi-persistent general storage plugin

I’m satisfied with a solution now: It allows me to shuffle plain temporary variable values around while recording the last ‘used’ value pre-pended by the logged-in-user’s name to help keep their ‘stuff’ in a state they left it. I’m pretty happy. Thanks again Bloke.

…..

smd_put_var: This asks first if the value of pubdate exists (I think): The if_variable container keeps the nothingness at bay. Example – no pubdate variable exists or has been posted so a blank value overwrites the ‘session variable’ – Bad if empty form fields get submitted.

<txp:if_variable name="pubdate">
<txp:smd_var_put name="<txp:rvm_privileged_user type="name" />_pubdate" value="<txp:variable name="pubdate" />" />
</txp:if_variable>

Then, this allows for a new selection: I found it needed to load below smd_put_var because of the apparent load order. I keep this in another output_form called from the head.

<form name="do_vars" method="post">
<select name="pubbed[]">
<option value='<txp:smd_var_get name="<txp:rvm_privileged_user type="name" />_pubdate"'><txp:smd_var_get name="<txp:rvm_privileged_user type="name" />_pubdate" /></option>
<option value="">Make Choice</option>
<option value=""></option>
<option value="2009-11-02">2009-11-02</option>
<option value="2009-11-09">2009-11-09</option>
</select>
<a href="javascript:make_vars_button()">Load</a>
</form>

This lets the form ‘do_vars’ make the temporary variable called pubbed which gets used to build the user-unique variable:

<txp:php>if($_POST['pubbed']){$GLOBALS['variable']['pubdate']=implode(',',$_POST['pubbed']);
}</txp:php>

note: the js was:

<script language="JavaScript">
function make_vars_button() {
    document.do_vars.submit();
}</script>

I think I now have the base work done so I can continue on and build prefs for users and record moves they make (for helpful reasons). This is great!

Last edited by whaleen (2009-11-20 02:55:36)


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#45 2009-11-19 08:46:52

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

Re: Semi-persistent general storage plugin

whaleen

I’m still subscribed :-)

Thanks for the kudos on the plugin and the excellent example of its use. Using it to track proper SESSION vars (without you having to muck about in PHP) is still one of the goals of the plugin, though I kind of forgot about it and left it decaying on the shelf. Perhaps now that 4.2.0 is out and smd_query, smd_if and smd_each are mature — not to mention that I’ve learnt a thing or three about TXP since this was released — I should revisit the plugin and polish it a little.

If you can think of a way the plugin can be used to streamline your use case here, or ways the plugin can be improved to ease any possible future uses of it, please let me know. Would like to really get this one smokin’ and release it officially.

Last edited by Bloke (2009-11-19 08:47:30)


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

#46 2009-11-20 02:14:17

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: Semi-persistent general storage plugin

Perhaps now that 4.2.0 is out and smd_query, smd_if and smd_each are mature — not to mention that I’ve learnt a thing or three about TXP since this was released — I should revisit the plugin and polish it a little.

I for one would be be happy for it, though it appears to be seaworthy from my perspective, save a few minor aspects which are related to other tags playing with this. I’m trying to get a grip on using smd_vars and smd_if together first. One thing I’ve attempted to say using the various field attribute choices:

this is psuedo code:

<txp:smd_if   variable-put-from-smd-var   operator="eq"  the-thing-it-might-be-equal-to>
Hurrah!
<txp:else />
Some alternative to variable-put-from-smd-var or nothing.
</txp:smd_if>

I’m trying it this way because I’m finding that <txp:variable /> and <txp:if_variable /> cannot use “smd-made-session-vars” in the context I’d like. Maybe not at all even? It isn’t only because I’m pre-pending a username to each variable name in order to create a mandatory name prefix for “user-owned” vars: I must have <txp:ign_user_info type="name" /> in use to retrieve the correct variable:

<txp:if_variable name='<txp:smd_var_get name="<txp:ign_user_info type="name" />_pubdate" />'></txp:if_variable>

This by itself returns the variable value I need by name:

<txp:smd_var_get name="<txp:ign_user_info type="name" />_pubdate" />

So I may need to try and load all session vars and “register” them as “temporary-per-page-load” vars in a native-TXP-usable shape. Would this approach be to long-winded or does something from smdpattern :) have an alternative?

I’m going to give that a shot and report back.

Would like to really get this one smokin’ and release it officially.

I’ll see if I can break it first!


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#47 2009-11-20 02:54:54

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: Semi-persistent general storage plugin

My latest scenario with if Var usable now:

Post Temporary Variable:

<txp:php>if($_POST['pubbed']){$GLOBALS['variable']['pubdate']=implode(',',$_POST['pubbed']);}</txp:php>

Convert Posted Temporary Variable to Session Variable:

<txp:if_variable name="pubdate">
<txp:smd_var_put name="<txp:ign_user_info type="name" />_pubdate" value="<txp:variable name="pubdate" />" />
</txp:if_variable>

Declare each page load that a Session Variable should be a Temporary Variable:

<txp:variable name='<txp:ign_user_info type="name" />_pubdate' value="<txp:smd_var_get name="<txp:ign_user_info type="name" />_pubdate" />" />
  • In the end, all Temporary Variables are identically named for all users and work for non-logged-in users.
  • All my logged-in-users get those same variable converted into ones with their username as a prefix and are stored for later use (after they log back in next week, after they come back in a new tabs, etc…).

Last edited by whaleen (2009-11-20 02:55:52)


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

#48 2009-11-20 03:25:37

whaleen
Member
From: Portland
Registered: 2006-05-11
Posts: 373
Website

Re: Semi-persistent general storage plugin

I may be way off base with some of these last posts. I think I’ve confused myself into a corner. My if_variable commands are not adding up. edit: Was due to not using single quotes in nested tags. Phew, that was close.

Last edited by whaleen (2009-11-20 03:44:37)


txtstrap (Textpattern + Twitter Bootstrap + etc…)

Offline

Board footer

Powered by FluxBB