For your case
$site = $request->variable('site', 1);
1will be the default when no value was given).
From your example in the opening post, I assumed you wanted a parameter of integer value
and the development documentation as a general overview: https://area51.phpbb.com/docs/dev/The $request->variable() method determines the type to set from the second parameter (which determines the default value too). If you need to get a scalar variable type, you need to tell this the variable() method explicitly
Don't feel bad. I am very grateful to get the working line and it was only a matter of testing twice to get the string working.From your example in the opening post, I assumed you wanted a parameter of integer value
I forgot to mention the coding guidelines which reference this behaviour: https://area51.phpbb.com/docs/32x/codin ... ml#general
In posting.php mode=reply/comment/quote is formatted likecatwiesel wrote: ↑Fri Jun 22, 2018 8:34 amIt works.
I noticed something though.
When you set the default to an integer, the variable will always be an integer.
If you put it in quotes and therefore as a string, you also can use strings.
?site=admin wont work with ('site',1)
?site=2 will work with ('site',1)
?site=admin will work with ('site','1');
Again, thank you!
Code: Select all
$mode = $request->variable('mode', '');
Users browsing this forum: No registered users and 17 guests