WebsiteBaker Support (2.8.x) > Droplets & Snippets

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

<< < (2/8) > >>

marathoner:
This works great for me and saves time when tweaking pages.

However, I'm having a problem. This snippet works fine for every page except my 'home' page which happens to be $page_id=1. Has anyone else had a problem using this snippet with $page_id=1? If so, is there a solution?

dellington:
I love this! This will be really great for some of the folks I build websites for. Thanks!!

DGEC:
I was trying to figure out why my implementation of this didn't work until I realized that I was on Home as well. I guess we'll just have to hardcode IF id="" then ID=1 or whatever your home page code is (mine is 3, must have deleted it twice I guess)

Vincent - good idea, but your code got cut off at the end. 

So here's my combined solution!


--- 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"><?php 
      echo $TEXT[&#39;ADMINISTRATION&#39;]; ?></a><br />
  <a href="<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php 
      if ($page_id) 
         echo $page_id; 
      else 
         echo "3";
      ?>" target="_blank"><?php echo $HEADING[&#39;MODIFY_PAGE&#39;]; ?></a>
  <?php
     }    
    ?>     

--- End code ---

icouto:
Wow! This hint is SOOO useful!

Is there a way to automatically find out what the id of the home page is without having to hard-code it? I ask because I can imagine some of my clients deleting the home page, making another one, and causing the link to fail.

DGEC:
You mean... like I did?  :lol:

That's a good point. You might have to just tell them not to do that, I couldn't figure out another way to do it without mucking into the core further and I didn't have time to do that.

It would be best to integrate this function into the system, and have it as an option on Settings, like Log In and Search.

Actually another thing I've been wanting to try doing is a "view page as guest/member/non-admin" function. I remember seeing that on another CMS and thinking how useful that would be. They implemented it as a fixed administrator menu option.  That method sounds like a lot of work for WB.

One quick mod might be to change the Edit Page link to a drop-down listbox with Edit as the first option, and "View as Guest,..." and then display the rest of the types in the Group database.  The view link could pass a parameter and a refresh would then automatically bring back the edit/view menu, hopefully.  Similar to the template preview function - it can work for one page view, but harder to make it sticky.  If it was an available value like the test if you're signed in or not, then you could turn it on and off.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version