Topic Closed
fly06
263 Posts
20.6K Downloads
1 Themes
8 Plugins

Hello,

I managed to extend the Simple_Blog plugin.

I mean that I have created a new plugin called Simple_Blog_Extended which is not a fork of Simple_Blog but is built by extending the Simple_Blog classes.

So far I am using this extended version to override the Simple_Blog templates and I also plan to add new features.

The only (current) drawback is the need to hack the common::GetUrl() method to enable the Simple_Blog_Extended plugin to change the $href parameter.

The hacked GetUrl() method:

function GetUrl($href='',$query='',$ampersands=true,$nonce_action=false){
global $linkPrefix, $config, $gp_index;
 
// Start - Hack Fly06
$href = gpPlugin::Filter('GetUrl',array($href));
// End - Hack Fly06
 
// THE REMAINING CODE IS UNCHANGED
 
}
 
and this the way I use it:
 
function GetUrl($href) {
 
switch ($href) {
case 'Special_Blog':
$href = 'Special_Blog_Extended';
break;
case 'Admin_Blog':
$href = 'Admin_Blog_Extended';
break;
case 'Admin_BlogCategories':
$href = 'Admin_BlogExtendedCategories';
break;
}
 
return $href;
 
}
 
If this way of extending a plugin would happen to be generic, adding the above hack to gpEasy v3.5 would help to promote the concept among the gpEasy developpers but also themes creators.
 
Any comments are welcome.

 

Edited: 10 years ago#4890

Josh S.
2K Posts
304K Downloads
16 Themes
18 Plugins

Looks like a good spot for a hook to me. How about this:

$filtered = gpPlugin::Filter('GetUrl',array(array($href,$query)));
if( is_array($filtered) ){
    list($href,$query) = $filtered;
}

Edited: 10 years ago#4897

fly06
263 Posts
20.6K Downloads
1 Themes
8 Plugins

It sounds good to me.

Adding the $query parameter might also be useful, that's true.

Thanks.

10 years ago#4899

fly06
263 Posts
20.6K Downloads
1 Themes
8 Plugins

 

This code works fine in most cases.
 
However I recently found that it raises a fatal error when one is trying to log in with a wrong login/password.
 
PHP Fatal error:  Class 'gpPlugin' not found in /include/common.php on line 1609
 
I solved this problem by making sure the gpPlugin class is loaded before the common::sessions() call in the EntryPoint() method.
 
function EntryPoint($level=0,$expecting='index.php',$sessions=true){
 
// SOME LINES OF CODE
 
includeFile('tool/Plugins.php');
 
if( $sessions ){
common::sessions();
}
 
//includeFile('tool/Plugins.php');
}
 
But I am unsure about the potential (?) unwanted by-side effects of this change.
10 years ago#4912

Josh S.
2K Posts
304K Downloads
16 Themes
18 Plugins

But I am unsure about the potential (?) unwanted by-side effects of this change.

There won't be any, the gpPlugin.php file doesn't do anything when it's loaded other than make the plugin functions available.

Thanks for the fix!

10 years ago#4914

Topic Closed

 

News

elFinder 2.1.50 in Upcoming Release
12/28/2019

A new release for Typesetter is in the works with a lot of improvements including the ... Read More

Typesetter 5.1
8/12/2017

Typesetter 5.1 is now available for download. 5.1 includes bug fixes, UI/UX improvements, ... Read More

More News

creisi productions

Dienstleistungen von creisi productions, Ennetb├╝rgen (Schweiz): * Konzeption, Planung und Erstellung Ihres Internet-Auftritts * Betreuung und Aktualisierung/Pflege Ihrer Websi...

Find out more about our Provider Spotlight

Log In

  Register