1 2015-07-26 18:29:43

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).

2 2015-07-26 18:57:49

Re: Edit page link if logged in?

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

(с) Roman Art
So far So good wink

RomanArt's Website

3 2015-07-26 20:53:16

Re: Edit page link if logged in?

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 ="edit"; //clumsy :)
                        echo " ".$part4;
                    } else {
                    }

Re: Edit page link if logged in?

well so u can use this code to hide ur code smile

(с) Roman Art
So far So good wink

RomanArt's Website

Re: Edit page link if logged in?

this code works fine on locahost tho smile

            
edit"; //clumsy :)
                                                echo " ".$part4;
                                        } else {
                                        }
?>
(с) Roman Art
So far So good wink

RomanArt's Website

6 2015-07-27 14:32:38

Re: Edit page link if logged in?

What does this do

 

in addition to this?

Is it possible to merge these somehow?

I'm just trying to understand smile

Re: Edit page link if logged in?

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 smile

(с) Roman Art
So far So good wink

RomanArt's Website