Help with persisting and accessing form/site variable

genyded

Active Member
Hi,

Our users zre given a special url
such as "http://mysite/?myvar=3" which we then need to reference across a series of menus linked to articles containing links to one or more embedded Fabrik forms via the content plugin. So, each menu item will link to an article that has one of more of something similar to the following in it's body:

{fabrik view=form id=1 rowid=[myvar]}
{fabrik view=form id=3 rowid=[myvar]}

...that all works well on the INITIAL page load because the myvar variable is in the url string. We have also been able to persist the value in the site template using "$myvar = $app->getUserStateFromRequest( "$option.myvar", 'myvar', NULL);"

It is our hope to have this variable be stored in only one place after being pulled form the initial URL string and somehow referenced from all the subsequent articles linked to off the site menu that contain the Fabrik content plugin form links which need to soemehow reference the variable.

So:

1) Is the path we are going down the best way to approach something like this?
2) What is the best way to reference the variable across the menu links to the articles that contain the Fabrik content plugin references for all the embedded forms?
3) We are open to adding references in multiple places if needed (maybe via calc elements or something), but would prefer to have only one instance somewhere if possible
4) Keep in mind that the variable is "created" once per session from the user passing it in the initial url query string - this is the one factor we cannot alter
5) We can persist it using the method described above as a variable in the site template, just not sure if that's the best place and if so how can we then best reference it? If not, we are open to alternative persistence options
6) We are also open to append it the the menu link query string is if there is a way to do that and it is needed

Any and all ideas on how best to tackle this are appreciated and we are open to ANY alternate methods to meet the goal of having each embedded Fabrik form in each article linked to off each of the menu items be able to filter the form rows based on the variable's value.

TIA,
Dale
 
So myvar is not the Joomla userid?
Is there a DB table containing a relation between userid and myvar?
In this case or if myvar is in session vars or in a cookie you could use a list prefilter.
 
Hi Hugh,

No it is not a user id- if is the id of a table record.

There is not relationship since we will never know how many rows will exist.

I can make it work as a list filter on the initial load (which is "sticky" for the session), but we do not want the users to "see" the list, only the edit form for the current row. I am toying now with a list that only has the row id's in it and trying to make it pseudo-hidden via the content plugin in all the articles that contain the forms. That may work, but will be a pain to maintain.
 
Where you were setting the var in the session, you could instead try assigning it to the user. I've not exactly sure if this will work if the user is not logged in though so you should test it..........

PHP:
$myVar = JFactory::getApplication()->input->get('myvar');
 
if (!is_null($myVar))
{
  $user = JFactory::getUser();
  $user->set('myvar', $myVar);
}

then use this:

{fabrik view=form id=3 rowid=[$my->myvar]}
 
Thanks Rob!


That ALMOST works - even for non-logged in users... but I think there may be a Fabrik issue with refreshing users....

A guest user sets the variable initially via the url and everything works fine - including the form filter. That user is then prompted to log in after which the variable persists (I am echoing it on all pages/content changes), however the list filter no longer applies it for some reason. So - the exact same variable works in the Fabrik list until the user changes and even though the "new" user still has it set, the Fabrik form does not see it at that point.

I'll keep playing around and see what else I can figure out - SO CLOSE....
 
OK... if I refresh the page, the form data shows up - so this looks like some sort of caching issue.... even though I think I currently have all my caches turned off. Does Fabrik use ant internal form or user caching? Also does anyone know of a quick easy way to force a page refresh on login?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top