Topic: Edit page link if logged in?
I'd like to have an "edit this page" link at the bottom of every page if I'm logged in.
(I searched this forum and also checked the documentation but I haven't come up with a good solution).
You are not logged in. Please login or register.
I'd like to have an "edit this page" link at the bottom of every page if I'm logged in.
(I searched this forum and also checked the documentation but I haven't come up with a good solution).
I know for sure u can add button with link which goes to admin/pages with list of all of them in template it will show only if u ar loged in and admin or editor, but idknw how to make the link exactly to the page editing, would be nice to know as well, if u can make that link somehow ill help u hide it from normall users and show only to admin/editor
I did a quick and dirty solution that only works for admin. I put the code in the footer.chunk.php.
(My programming skills are limited and I therefore cannot guarantee that this code is safe to use.)
if (Session::exists('admin') && Session::get('admin') == true) { // check whether admin is logged in and session is active list($part1, $part2, $part3) = explode('/', $_SERVER['REQUEST_URI']); //get the URI and split it into three parts if ($part3 == '') { //if third part is empty give it the value of the second part $part3 = $part2; } $part4 ="<a href='http://gdfoto.se/admin/index.php?id=pages&action=edit_page&name=".$part3."'>edit</a>"; //clumsy :) echo " ".$part4; } else { }
well so u can use this code to hide ur code
<?php if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) { ?> <a href="<?php echo Site::url(); ?>admin">Admin panel hiden</a> <?php } ?>
this code works fine on locahost tho
<?php if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) { ?> <?php if (Session::exists('admin') && Session::get('admin') == true) { // check whether admin is logged in and session is active list($part1, $part2, $part3) = explode('/', $_SERVER['REQUEST_URI']); //get the URI and split it into three parts if ($part3 == '') { //if third part is empty give it the value of the second part $part3 = $part2; } $part4 ="<a class='btn btn-info' href='/admin/index.php?id=pages&action=edit_page&name=".$part3."'>edit</a>"; //clumsy :) echo " ".$part4; } else { } ?> <?php } ?>
What does this do
<?php if (Session::exists('user_role') && in_array(Session::get('user_role'), array('admin', 'editor'))) { ?>
in addition to this?
<?php if (Session::exists('admin') && Session::get('admin') == true) {
Is it possible to merge these somehow?
I'm just trying to understand
I have no idea lol, i dont know php at all... I had that code in my notes with explanation of wht it does, so i try to make ur code plus that one to work together and it does, buttons showes only to admin or editor if they loged in, the only problem it works only on plugin pages and it wont work if u ar at yourwebsite.com/index.php only if its has home or any pages after slash otherwise buttons sending u to hell