When the user will click on the button :
1. User comes from a view, and his browser can manage cookie => go to the view
at the "good" position (url is in the cookie)
2. User comes from a view, and his browser cannot manage cookie and the
document is in edit mode => go to the "begin" of the view (with @viewtitle)
3. Browser cannot manage cookue and the document is in read mode => go to the
begin of the default view (with the view indicated in the field DefaultView).
That's it !
You can also put a formula like this in the $$Return : "[" + ViewReferer + "]"
; so when user submit a document he get back directly to the view at the good
position.
My english is quite bad, but I hope now everybody will get the trick...
Hello,
Because recently I received a mail asking to me details about the technic of cookie, I complete my previous message :
A/ ------------------------------
In the $$ViewTemplateDefault, put this code in the UnLoad event :
doCookie("ViewReferer", location.href);
In the JS Header, copy this code :
function doCookie(cookieName, value) { if(document.cookie) { index = document.cookie.indexOf(cookieName); } else { index = -1; } if (index == -1) document.cookie = cookieName+"=" + value + ";expires=Tuesday, 01-Apr-2020 08:00:00 GMT"; else { countbegin = (document.cookie.indexOf("=", index) + 1); countend = document.cookie.indexOf(";", index); if (countend == -1) { countend = document.cookie.length; } document.cookie=cookieName+"="+value+";expires=Tuesday, 01-Apr-2020 08:00:00 GMT"; } }
B/ ------------------------------
B 1. In the form used to access documents, put a field named HTTP_COOKIE, computed for display.
B 2. Just below, put another field named ViewReferer (for example), computed for display, with this code :
tmp := @Right ( HTTP_Cookie ; "ViewReferer=") ; tmp2 := @If ( @Contains(tmp ; ";") ; @Left( tmp ; ";") ; tmp ) ;
@If ( tmp2 = "" ; tmp ; tmp2 )
B 3. Put a field named DefaultView (for example), computed for display, and enter the name of the default view of your web application.
For example : "TopicsByDate" in the case of a forum.
B 4. Put a button or a Hospot named for example "Back to view", and enter this formula :
@SetTargetFrame("_self");
url := @If( ViewReferer != "" ; ViewReferer ; @Subset(@ViewTitle ; -1) != "" ; DbNameWeb + "/" + @Subset(@ViewTitle ; -1) + "?OpenView" ; DbNameWeb + "/" + DefaultView + "?OpenView" ) ;
@URLOpen(url)
What this code means ?
When the user will click on the button : 1. User comes from a view, and his browser can manage cookie => go to the view at the "good" position (url is in the cookie) 2. User comes from a view, and his browser cannot manage cookie and the document is in edit mode => go to the "begin" of the view (with @viewtitle) 3. Browser cannot manage cookue and the document is in read mode => go to the begin of the default view (with the view indicated in the field DefaultView).
That's it !
You can also put a formula like this in the $$Return : "[" + ViewReferer + "]" ; so when user submit a document he get back directly to the view at the good position.
My english is quite bad, but I hope now everybody will get the trick...
Kindest regards,
Fabrice P (France)