A list of functions

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

A list of functions

Post by Tata » Sat Sep 02, 2017 6:53 pm

It would be nice to have somewhere in one place a list of available functions for CMSimpl_XH-1.7.0.
RIght now I can't find the right usage for sitemap.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

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

Re: A list of functions

Post by cmb » Sat Sep 02, 2017 7:14 pm

Tata wrote:It would be nice to have somewhere in one place a list of available functions for CMSimpl_XH-1.7.0.
RIght now I can't find the right usage for sitemap.
See http://www.cmsimple-xh.org/dev-doc/php/ ... _8php.html. Note the search box!
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: A list of functions

Post by Tata » Sat Sep 02, 2017 8:46 pm

Thanks, I didn't know about this one. I have not found how to call the sitemap on a page.
E.g. here: http://cmsimple.sk/?Mapa-stranky
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

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

Re: A list of functions

Post by cmb » Sun Sep 03, 2017 8:39 am

Tata wrote: I have not found how to call the sitemap on a page.
There is no dedicated function, but you can use:

Code: Select all

<?php echo $_XH_controller->handleSitemap()?>
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: A list of functions

Post by Tata » Sun Sep 03, 2017 12:32 pm

Thanks, Chris. It works in a template. But I thought about replacement for a function used on a page. E.g.

Code: Select all

<h1>Site Map</h1>
{{{shosSitemap();}}} 
Maybe this would work with userfunction?

Code: Select all

function showSitemap()
{
global $pth, $h;
echo $_XH_controller->handleSitemap();
}
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

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

Re: A list of functions

Post by cmb » Sun Sep 03, 2017 12:55 pm

Tata wrote:Maybe this would work with userfunction?
Yes, but you have to declare $_XH_controller as global:

Code: Select all

function showSitemap()
{
    global $_XH_controller;
    echo $_XH_controller->handleSitemap();
} 
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: A list of functions

Post by Tata » Sun Sep 03, 2017 3:56 pm

Super!!! It works excellent. Shouldn't it go in core functions.php? And maybe also other unique functions modified under older version? E.g. iconized print/printlink, sitemap/sitemaplink, mailform/mailformlink,loginlink etc. With eventual options in configuration.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

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

Re: A list of functions

Post by cmb » Mon Sep 04, 2017 6:10 pm

Tata wrote:Shouldn't it go in core functions.php? And maybe also other unique functions modified under older version? E.g. iconized print/printlink, sitemap/sitemaplink, mailform/mailformlink,loginlink etc. With eventual options in configuration.
I'm not generally against adding such functions, but I don't think adding lots of unprefixed functions in the global namespace is a good idea in the long run, since the risk of nameclashes increases. Consider a user has already a function sitemap in userfuncs.php (or maybe in a plugin), perhaps doing something different. If we add sitemap() to the core, there would be a fatal PHP error.

I also don't like adding prefixes like XH_ (i.e. to name the function XH_sitemap()). This is a relict of the past, but as of PHP 5.3.0 there are namespaces, so Xh\sitemap() would be preferable[1]. Currently, the plugin call doesn't support namespaced functions, but this could easily be fixed.

[1] Note that this is not about that Xh\sitemap() is easier to write or read than XH_sitemap(), but rather that internally the namespace can be omitted what leads to better readable code.
Christoph M. Becker – Plugins for CMSimple_XH

Tata
Posts: 3586
Joined: Tue May 20, 2008 5:34 am
Location: Slovakia
Contact:

Re: A list of functions

Post by Tata » Mon Sep 04, 2017 10:19 pm

How would it then be with a "patch" file with such prefixed functions and a help file with explanation how to use them instead of standard core functions?
in this case there could be used either e.g.
- sitemap(); or XH_sitemap();
- previouspage(); or XH_previouspage
- toplink(); or XH_toplink();
etc.
Such file could then be continuosly actualized and put downloadable somewhere.
CMSimple.sk
It's no shame to ask for an answer if all efforts failed.
But it's awful to ask without any effort to find the answer yourself.

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

Re: A list of functions

Post by cmb » Mon Sep 04, 2017 10:53 pm

Tata wrote:How would it then be with a "patch" file with such prefixed functions and a help file with explanation how to use them instead of standard core functions?
Well, this could be done by a small plugin, which would need only index.php and help.htm, but version.nfo (and maybe more) would be nice. In this case I would suggest to use the plugin name (or perhaps an abbreviation) as prefix, maybe tplx_sitemap() etc. (where tplx would mean "template extensions"). Having such a plugin (or perhaps multiple plugins) might be interesting; if many users would be interested in this plugin or at some of its functionality, we could consider moving the respective parts into the core later.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply