Hi,
how is it better possible to show hide a Column via URL
I got some results with the code on top of the page:
<?php
$columnhidestatus= $_GET["columnhidestatus"]; if (!isset($columnhidestatus)) $columnhidestatus= true;
?>
And within the columns:
$col = array();
$col["title"] = "column"
$col["name"] = "column";
$col["hidden"] = $columnhidestatus;
$cols[] = $col;
When calling website.com?columntohide=false it hides the column, if its not set in url, telling "hidden=true". But It does not work for more columns. Is there another more secure way for this?
This feature would allow to make accesscontroll, via URL who may edit a column who not. The editor would need to know the variablename like "columnhidestatus", if he does not know he can not edit. However this works only for 1 column…
Best regards,
Mario
I found out that it works with
code on top of the page:
<?php
$w= $_GET["w"]; if (!isset($w)) $w= 0;
?>
And within the columns:
$col = array();
$col["title"] = "column"
$col["name"] = "column";
$col["width"] = $w;
$cols[] = $col;
For more than one column … you can set multiple querystring params and set with each column.
e.g.
$col["name"] = 'gender';
$col["hidden"] = ( isset( $_GET["gender_hide"] ) ? true : false );
$col["name"] = 'company';
$col["hidden"] = ( isset( $_GET["company_hide"] ) ? true : false );
Now if you set:
http://domain/page.php?company_hide=1&gender_hide=1
Both will be hidden.
Regarding security, this does not looks to be a good way.
Ideally, you must integrate some authentication and based on session data, either define or undefine whole column.
e.g.
if ($_SESSION["role"] == 1)
{
$col = array();
$col["title"] = "gender";
$col["name"] = "gender";
$col["width"] = "20";
$cols[] = $col;
}
Cool:
I turned the range from true:false to false:true
$col["hidden"] = (isset($_GET["showcolumn_xy"])?false:true);
$col["hidden"] = (isset($_GET["showcolumn_yz"])?false:true);
So the column is hidden by default, and only if someone nows its name, it will be shown with URL like:
http://domain/page.php?showcolumn_xy=1&showcolumn_yz=1
This is not most secure, but easy way.
Best regards,
Mario
.. it does not work with
$col["editable"] = (isset($_GET["columntoedit"])?false:true);
and:
http://domain/page.php?columntoedit=1
Idea why?
… it works, with in header:
—
<?php
$editcolumns = $_GET["editcolumns"]; if (!isset($editcolumns)) $editcolumns = false;
?>
—
And in set_actions-array:
—
"edit"=>$editcolumns, //..
—
This way one can fully controll the access and editpermissions by knowing the variables names.
url not editable by default:
http://domain/page.php
url editable with parameter:
http://domain/page.php?editcolumns=1