Hey everybody,
One thing I really wanted to do on a recent project was have an "edit this page" link to give my clients quick access to PageLime editing.
I'm not PHP guru, to be sure, but I found a quick and easy way to do.
The key is understanding how PageLime links to your pages when in editing mode.
The first part of the URL looks like this: http://cms.pagelime.com/CMS/?/#/editor/$/RequestedEditURL=
After that things get a little funky. Colons (:) are represented by the combination @3A and slashes (/) are represented by @2F.
The last part of the URL is a unique ID for each website you have set up with PageLime. This is tacked on the end of the URL as /RequestedSiteID=<strong>XXXX</strong> where XXXX is the four digit code for your particular website. You can figure out your site ID by logging in to PageLime like normal, selecting the site you want to edit and then looking in the address bar. The last four digits in the URL are your site ID.
Let's put this all together. If the URL you want to edit is http://www.ywamozarks.com/index.html, the PageLime URL where you edit it is going to look like this http://cms.pagelime.com/CMS/?/#/editor/$/RequestedEditURL=http@3A@2F@2Fwww.ywamozarks.com@2F@2Findex.html/RequestedSiteID=XXXX.
So, to put a dynamic link on each page that will let your users edit that particular page, we'll just need to use PHP to pull in the current URL and append that to the standard PageLime URL.
Here's the code to do it.
<a href="http://cms.pagelime.com/CMS/?/#/editor/$/RequestedEditURL=http@3A@2F@2Fwww.yourwebsite.com@2F
<?php
// first we need to find out the path to the current file
$path = $_SERVER['SCRIPT_NAME'];
// now let's replace the slashes with PageLime's @2F symbols
$path = str_replace('/', '@2F', $path);
// and now we're ready to spit out the results
echo $path;
?>
/RequestedSiteID=XXXX <?php //Remember to replace XXXX with your site's ID ?>
" title="Edit this page in PageLime">Edit this page</a>
That's it! If you put this code into a PHP include, you'll have a nice link to edit every page of the site, even when new pages are added. It should even work within folders and sub-folders.