Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"Edit this page"
#1
Some ideas for having an "Edit this page" button/link in GetSimple live pages (like in Blogger, some WP themes, etc.)

1. Javascript bookmarklet
A small JS script that extracts the slug of the current page, then opens 'admin/edit.php?id=...'
This one could be useful for editing *any* GetSimple site. Of course it must be "installed" in your browser.

2. In the GS theme
Insert this somewhere in template.php:
Code:
[<a href="admin/edit.php?id=<?php echo return_page_slug(); ?>">edit this page</a>]
Remove it e.g. when you've finished setting up the site and going to make it public.
(this works, it is what I'm using while developing in localhost)

3. Same, but only show button/link if user logged in (CODE DOES NOT WORK ;-))
Code:
<?php if(***LOGGED IN***, ) {
    echo '[<a href="admin/edit.php?id='.return_page_slug().'">edit this page</a>]';
    }
?>
Sorry I'm not PHP skilled, and still beginning with GS. Could this be feasible?
Reply
#2
Carlos Wrote:A small bookmarklet that extracts the slug of the current page, then opens 'admin/edit.php?id=...'
I’m going to grab some tea first, but will create this one afterwards.

Carlos Wrote:Only show button/link if user logged in
There has been talk about this before. But currently there is no way to check whether the user is logged in or not.

Edit: I see no fault-proof way for Javascript to know what part of the URL the page’s ID is. I’ll have to think about this a little longer I suppose.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#3
This could be a great set of plugins! It would be pretty easy to set up a cookie that would say there is a user loges in if we could have a plugin hook after the login check but before the redirect is launched?

I will work on this later on!
JWH Technologies
Have any marketing ideas for Get-Simple? Let me hear them!
Reply
#4
I've developed a plugin for this: EditThisPage for GetSimple

Note that it is a VERY beta version. Comments, suggestions, corrections... are very welcome, especially about the code.

I'm not sure if I'm doing right (with cookies, includes...). If some PHP coder takes a look at the source I'd thank a lot...
Reply
#5
It seems everything is working, thanks, very useful plugin
Reply
#6
Just an idea, Might be great if this could this be added to Blog plugin entries to create a Mini_Blog on steroidsSmile Mini Blog right now is more of a really good news Plugin but not really a Blog in my opinion
Reply
#7
Very interesting and useful if you guys could pull it off. I haven't tried to the plugin yet - but this would be great!
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#8
daguy Wrote:Just an idea, Might be great if this could this be added to Blog plugin entries to create a Mini_Blog on steroidsSmile

Mini_blog version 0.4:
edit mini_blog.php, insert this between lines 153-169 or so (e.g. in line 162, after the post date):

Code:
if( function_exists('editthispage_check') && editthispage_check() ) {
                    echo '<div class="editthispost"><a href="';
                    get_site_url();
                    echo 'admin/load.php?id=mini_blog&edit='.$post['id'].'">Edit</a></div>';
                }
Reply
#9
Hi there
=-00-0=
GS version : 2.01 (stable downloaded)

I made a edit page plugin.. but it required me to change 2 files of the GS system.

I added a new config option to make cookies site wide. this needs to be added and enabled in gsconfig.php

Code:
#make Cookies site wide available
#define('GSCOOKIEISSITEWIDE', TRUE);

I also needed to change the cookie_functions.php file.
I change the create_cookie and kill_cookie functions.

kill_cookie was changed to

Code:
function kill_cookie($identifier) {
        global $SALT;
        $saltCOOKIE = $identifier.$SALT;
        if (defined('GSCOOKIEISSITEWIDE')) {
             $_COOKIE[$saltCOOKIE] = FALSE;
           setcookie($saltCOOKIE, FALSE, time() - 3600,'/');    
        } else {
            $_COOKIE[$saltCOOKIE] = FALSE;
            setcookie($saltCOOKIE, FALSE, time() - 3600);
            
        }
    }

and create_cookie was changed to

Code:
function create_cookie() {  
      
        global $USR;
        global $SALT;
        global $cookie_time;
        global $cookie_name;
        $saltUSR = $USR.$SALT;
        $saltCOOKIE = $cookie_name.$SALT;
        if (defined('GSCOOKIEISSITEWIDE')) {
          setcookie($saltCOOKIE, sha1($saltUSR), time() + $cookie_time,'/');    
        } else {
            setcookie($saltCOOKIE, sha1($saltUSR), time() + $cookie_time);        
        }
    }

and then ALL that needs to be done is the plugin needs to be installed under the plugins dirs.

Hope this can help somebody..

Note by default the plugin will not work as they cookie is only available under /admin
until the gsconfig.php is changed to enable GSCOOKIEISSITEWIDE

I have attached a file with the plugin and the files that was changed.
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
Reply
#10
Nice one, that might be a function we should start distributing within the core.

One nitpick comment though, don’t use:
Code:
if (defined('GSCOOKIEISSITEWIDE'))
It’s better to use:
Code:
if (defined('GSCOOKIEISSITEWIDE')&&GSCOOKIEISSITEWIDE==true)
That way people can set it to “false” if they want to disable it again as well. It’s better to have it working as a toggle than as something that has to be commented out.

This is something we’ll work on in the core as well, especially with the debug setting which should also be able to be false.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#11
Good point, will do so.. Will add when I get home tonight

thanks for looking at it.

Hope it can help somewhere.
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
Reply
#12
Zegnåt Wrote:Nice one, that might be a function we should start distributing within the core.

One nitpick comment though, don’t use:
Code:
if (defined('GSCOOKIEISSITEWIDE'))
It’s better to use:
Code:
if (defined('GSCOOKIEISSITEWIDE')&&GSCOOKIEISSITEWIDE==true)
That way people can set it to “false” if they want to disable it again as well. It’s better to have it working as a toggle than as something that has to be commented out.

This is something we’ll work on in the core as well, especially with the debug setting which should also be able to be false.

Hi there.. Updated the cookie_functions.php file as per your advise. Attached is the file.
Have a nice day.
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
Reply
#13
the is a path problem with this plugin.

the function is :

Code:
function content_check($contents){
  $tmpContent =  $contents;
  if (plugin_login_check() == TRUE) {
    $slug = return_page_slug();
    $tmpContent .= "<br/><p><a href='admin/edit.php?id=$slug'>Edit this Page</a></p>";
  }

the problem is here :
Code:
<a href='admin/edit.php?id=$slug>

When you are on a subpage for exemple, the path become mydomain/first-page/subpage/admin/edit.php?... so it's wrong.

Maybe in using GSADMINPATH it will be better (cf http://get-simple.info/docs/plugin-creation )
Reply
#14
gdsadminpath will give back servers local path to files not the url path. Will check how to handle if subpage as never thought to test on that. thanks will look into it.
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
Reply
#15
good Smile Hope you find the solution Wink
Reply
#16
$URL (I think) holds the path to where GetSimple is in the way you want it. Since the above only happens when Fancy URLs are enabled you might want to test for that in your plugin.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#17
Thanks. Will look at it else I wrote functions that I use in my common unit that I share between my plugins that figures the url out for me. Might use that and update this plugin as it was before I started writing the url..

It looks as following (sorry english part of brain not working today)

Code:
function getBaseSiteURLandAddChar(&$baseURL,&$addChar){
//get the base url for normal or FANCY URL's.. if fancy it will remove all added values and keep url string for normal it will insure the id gets kept
  $baseURL = $_SERVER["REQUEST_URI"];
  if (strpos($baseURL,'?id=') !== false) {
    $id = $_GET['id'];
    $baseURL = preg_replace("/\?id=.*/i","",$baseURL);
    $baseURL .= "?id=$id";
    $addChar = '&';
  }  else {
    $addChar = '?';  
    $baseURL = preg_replace("/\?.*/i","",$baseURL);
  }
}
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
Reply
#18
Urg... that wont work as the URL is at the client side page and not the admin one. I will have to read the pages files and see if it has parent and build up url for that.. will have to do later first have to finish as Cart system I am doing for somebody now.

tx
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
Reply
#19
At first I had this same problem with the URL path with my EditThisPage plugin ( http://get-simple.info/forum/post/6074/#p6074 )

You may use global variable $SITEURL, inserting it just before "admin/edit.php?..." -- it will be a full URL instead of a relative one)
Reply
#20
thanks, will look at.. thank you..
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
Reply




Users browsing this thread: 2 Guest(s)