Posts: 3,491
Threads: 106
Joined: Mar 2010
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?
Posts: 972
Threads: 27
Joined: Aug 2009
2010-03-15, 02:13:24
(This post was last modified: 2010-03-15, 03:22:08 by vsky.)
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.
Posts: 679
Threads: 80
Joined: Nov 2009
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!
Posts: 3,491
Threads: 106
Joined: Mar 2010
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...
Posts: 1,927
Threads: 88
Joined: Apr 2010
It seems everything is working, thanks, very useful plugin
Posts: 22
Threads: 3
Joined: Jun 2010
Just an idea, Might be great if this could this be added to Blog plugin entries to create a Mini_Blog on steroids Mini Blog right now is more of a really good news Plugin but not really a Blog in my opinion
Posts: 1,848
Threads: 86
Joined: Aug 2009
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!
Posts: 3,491
Threads: 106
Joined: Mar 2010
daguy Wrote:Just an idea, Might be great if this could this be added to Blog plugin entries to create a Mini_Blog on steroids
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>';
}
Posts: 407
Threads: 22
Joined: Aug 2010
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.
Posts: 972
Threads: 27
Joined: Aug 2009
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.
Posts: 407
Threads: 22
Joined: Aug 2010
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.
Posts: 407
Threads: 22
Joined: Aug 2010
2010-09-14, 14:24:30
(This post was last modified: 2010-09-14, 14:25:49 by tariq123.)
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.
Posts: 37
Threads: 7
Joined: Feb 2010
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 )
Posts: 407
Threads: 22
Joined: Aug 2010
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.
Posts: 37
Threads: 7
Joined: Feb 2010
good Hope you find the solution
Posts: 972
Threads: 27
Joined: Aug 2009
$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.
Posts: 407
Threads: 22
Joined: Aug 2010
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.
Posts: 407
Threads: 22
Joined: Aug 2010
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.
Posts: 3,491
Threads: 106
Joined: Mar 2010
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)
Posts: 407
Threads: 22
Joined: Aug 2010
thanks, will look at.. thank you..
Stopped developing on GS Plugins. Anybody welcome to take the projects over. Thanks for all the support all.
|