WebsiteBaker Support (2.8.x) > Droplets & Snippets

Handy "edit this page" link when your logged in!

(1/8) > >>

englishdingbat:
I wanted a way to quickly edit the page when I was on it, so i just added this simple bit of code in to my template. Place where ever it is convenient for you, but it only shows when you are logged in. You must have login enabled in prefs, but someone might be able to hack the code further???



--- Code: ---<?php
 if(FRONTEND_LOGIN == &#39;enabled&#39; AND is_numeric($wb->get_session(&#39;USER_ID&#39;))) {
?><a href="<?php echo ADMIN_URL; ?>/index.php"><?php echo $TEXT[&#39;ADMINISTRATION&#39;]; ?></a><br />
<a href="http://[you-website.domain]/admin/pages/modify.php?page_id=<?php echo $page_id; ?>">Edit Page</a>
<?php
}
?>
--- End code ---

simple i know, but useful.
Pete

pcwacht:
Very good idea, 1 improvement though, the second url, doens't make use of the ADMIN_URL yet, change to:



--- Code: ---<?php
       if(FRONTEND_LOGIN == &#39;enabled&#39; AND is_numeric($wb->get_session(&#39;USER_ID&#39;))) {
      ?><a href="<?php echo ADMIN_URL; ?>/index.php"><?php echo $TEXT[&#39;ADMINISTRATION&#39;]; ?></a><br />
<a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>">Edit Page</a>
      <?php
      }
      ?>
--- End code ---

I suggestion, maybe a  check to see if the logged in user is admin or has the rights to edit the page??

John


baZzz:
Very handy indeed, good job!
A little improvement, in case you have a multilingual website, you might want to do this:

--- Code: ---<?php
if(FRONTEND_LOGIN == &#39;enabled&#39; AND is_numeric($wb->get_session(&#39;USER_ID&#39;)))
{
  ?>
  <a href="<?php echo ADMIN_URL; ?>/index.php"><?php echo $TEXT[&#39;ADMINISTRATION&#39;]; ?></a><br />
  <a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>"><?php echo $HEADING[&#39;MODIFY_PAGE&#39;]; ?></a>
  <?php
}
?>

--- End code ---

felix_se_cat:
check to see if logged in user is an admin could be done with:
if ($wb->get_session('GROUP_ID')==1)

(i did so and it works fine for me)

Vincent:
Very handy indeed!

I slightly refined it (open new window). Thanks.
Vincent


--- Code: ---<?php
if(FRONTEND_LOGIN == &#39;enabled&#39; AND is_numeric($wb->get_session(&#39;USER_ID&#39;)))
if ($wb->get_session(&#39;GROUP_ID&#39;)==1)
{
  ?>
  <a href="<?php echo ADMIN_URL; ?>/index.php"target="_blank"><?php echo $TEXT[&#39;ADMINISTRATION&#39;]; ?></a><br />
  <a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>"target="_blank"><?php echo $HEADING[&#39;MODIFY_PAGE&#39;]; ?></a>

--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version