Add optional parameter to top()

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:

Add optional parameter to top()

Post by cmb » Sun Feb 08, 2015 9:01 pm

Hello Community,

in a German thread knollsen has sugested to add an optional parameter to the template tag top() to be able to choose another ID instead of TOP. IMO that would be a nice and kompatible improvement.

I suggest the following patch:

Code: Select all

Index: cmsimple/tplfuncs.php
===================================================================
--- cmsimple/tplfuncs.php	(revision 1480)
+++ cmsimple/tplfuncs.php	(working copy)
@@ -632,17 +632,19 @@
 /**
  * Returns a link to the top of the page.
  *
- * To work, an anchor TOP has to be defined in the template.
+ * To work, an appriate ID has to be defined in the template.
  *
+ * @param string $id An (X)HTML ID.
+ *
  * @return string (X)HTML.
  *
  * @global array The localization of the core.
  */
-function top()
+function top($id = 'TOP')
 {
     global $tx;
 
-    return '<a href="#TOP">' . $tx['navigator']['top'] . '</a>';
+    return '<a href="#' . $id . '">' . $tx['navigator']['top'] . '</a>';
 }
Christoph M. Becker – Plugins for CMSimple_XH

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

Re: Add optional parameter to top()

Post by cmb » Mon Jun 01, 2015 12:41 am

Done (r1618).
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply