Individual modifications to the CMSimple_XH core

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Individual modifications to the CMSimple_XH core

Post by cmb » Sat Aug 06, 2011 6:17 pm

Hello community,

to be able to provide easy to install updates of the CMSimple_XH core for everyone, it might be necessary to introduce additional hooks, so that the core files musn't be changed individually.

CMSimple_XH introduced the possibility to use the file userfuncs.php already. This file is included from the core, but will not be distributed with it. So you can use the userfuncs.php to define new constants, variables, functions, classes etc. for use from the template or the content via CMSimple scripting. It is furthermore possible to include script code to userfuncs.php that will be evaluated at the global namespace, when the file is included. If extensive modifications are required, it's possible to include other script files from userfuncs.php.

userfuncs.php is included by functions.php. functions.php is included by cms.php very early, i.e. before the pluginloader and the template. So it should be possible to use userfuncs.php for the most cases of modifications you need.

Are there any other hooks, that might be missing to make modifications to CMSimple_XH without altering the core files?

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Martin
Posts: 346
Joined: Thu Oct 23, 2008 11:57 am
Contact:

Re: Individual modifications to the CMSimple_XH core

Post by Martin » Mon Aug 08, 2011 9:58 am

I never war enthusiastic about this userfuncs.php - it is somewhat redundant. There are two ways to integrate your own functionality that I like more: The stuff that is used just for a special template can be included from (or written to) the template.htm. More general enhancements can be put into a folder plugins/my_stuff. Both ways are older and I don't remember why we added userfuncs.php at all.

I would not call this includes a "hook", not in a classic sense. The only thing that comes close to a "hook" is $f. Here your scripts get informed about an action that CMSimple is about to perform and may change the default behaviour:

Code: Select all

if($f == 'search'){
    $f = 'xyz';
    $o .=  my_private_own_search();
} 
But I don't think its too bad that CMSimple has no real event dispatcher. At least when it comes to the point of frontend output. When the template is included everything you need is known and there are such a few variables and "output functions" that it is easy to filter and change them in the way you need it.

Code: Select all

<?php 
//echo content();
echo my_content();
?>
Martin

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: Individual modifications to the CMSimple_XH core

Post by cmb » Mon Aug 08, 2011 10:17 am

Hello Martin,
Martin wrote: Both ways are older and I don't remember why we added userfuncs.php at all.
As you pointed out: userfuncs.php is somewhat superfluos. But as it does already exist, it might be easier to grasp for an user to put his stuff into userfuncs.php than into a separate folder in plugins/
Martin wrote: The only thing that comes close to a "hook" is $f.
Thanks for pointing this out. :) Is it advisable to use the request parameter function, which is somewhat coupled to $f, for user defined operations?

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply