XH 1.6: Meta_tags: Description as Textarea

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

Re: XH 1.6: Meta_tags: Description as Textarea

Post by cmb » Fri Nov 30, 2012 4:25 pm

Hallo Gert,
Gert wrote:ich habe übrigens ein paar Posts vorher auf meine Veröffentlichung von CMSimple 4.0.2 verlinkt, weil dort die direkte Antwort auf die eigentliche Frage dieses Threads steht:
Stimmt, das hatte ich gesehen, aber schon wieder vergessen. Mir ging es aber gar nicht mal um die Konfiguration, sondern um den "Meta"-Tab oberhalb des Editors. Da ist es schon doof, dass man nur ein einzeiliges Input hat.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: XH 1.6: Meta_tags: Description as Textarea

Post by Holger » Tue Dec 11, 2012 11:14 am

cmb wrote:Hallo Holger,
Holger wrote:Sag' mir zum Beispiel einfach mal, wie man die Eltern-Seite der aktuell gewählten Seite leicht heraus bekommt. Wo steht das denn?
Oder noch schwerer: wie bekomme ich den Namen oder Index aller Unterseiten der aktuellen Seite heraus...?
Guter Punkt! Beides wird immer wieder mal gebraucht, und vor allem die Bestimmung der Unterseiten ist gar nicht mal trivial (wegen der Möglichkeit von unregelmäßigen Seitenstrukturen). Wie wäre es mit folgenden Funktionen für XH 1.6?

Code: Select all

/**
 * Returns the index of the parent page of page no. $n.
 * Returns null, if $n is a toplevel page.
 *
 * @param  int $n
 * @param  bool $ignoreHidden  Whether hidden pages should be ignored.
 * @return int
 */
function XH_parentPage($n, $ignoreHidden = true)
{
    global $l;
    
    for ($i = $n - 1; $i >= 0; $i--) {
        if ($l[$i] < $l[$n] && (!$ignoreHidden || !hide($i))) {
            return $i;
        }
    }
    return null;
}


/**
 * Returns the list of indexes of direct children of page no. $n.
 *
 * @param  int $n
 * @param  bool $ignoreHidden  Whether hidden pages should be ignored.
 * @return array of int.
 */
function XH_childPages($n, $ignoreHidden = true)
{
    global $cl, $l, $cf;
    
    $res = array();
    $ll = $cf['menu']['levelcatch'];
    for ($i = $n + 1; $i < $cl; $i++) {
        if ($ignoreHidden && hide($i)) {
            continue;
        }
        if ($l[$i] <= $l[$n]) {
            break;
        }
        if ($l[$i] <= $ll) {
            $res[] = $i;
            $ll = $l[$i];
        }
    }
    return $res;
}

/**
 * Returns the list of indexes of toplevel pages.
 *
 * @param  bool $ignoreHidden  Whether hidden pages should be ignored.
 * @return array of int
 */
function XH_toplevelPages($ignoreHidden = true)
{
    global $cl, $l;
    
    $res = array();
    for ($i = 0; $i < $cl; $i++) {
        if ($l[$i] == 1 && (!$ignoreHidden || !hide($i))) {
            $res[] = $i;
        }
    }
    return $res;
} 
Vielleicht sollte man $cf[menu][levelcatch] auch rausschmeißen und durch eine Konstante ersetzen. Bin aber nicht sicher, ob das von Plugins genutzt wird.

Auf jeden Fall kann mit XH_toplevelPages() und XH_childPages() sehr schön rekursiv über alle Seiten iterieren. Bzgl. hide() hatte ich schon angeregt, dessen Ergebnis zu cachen.

Christoph
Hi Christoph,

ich arbeite gerade die Roadmap für 1.6 ab.

Solche Funktionen hätte ich ja sehr gerne zur Verfügung.
Aber wohin sollen solche Sachen, die ja (noch) nicht lebensnotwendig für den Core sind, denn hin?
Noch eine extra Include-Datei? Functions.php? Oder nicht doch lieber eine Art Utility-Plugin?

BTW: "levelcatch" würde ich beibehalten.

LG
Holger

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

Re: XH 1.6: Meta_tags: Description as Textarea

Post by cmb » Tue Dec 11, 2012 12:20 pm

Hallo Holger,

I've just noticed, that this discussion is in OD. So I'll switch back to English.
Holger wrote:Aber wohin sollen solche Sachen, die ja (noch) nicht lebensnotwendig für den Core sind, denn hin?
Noch eine extra Include-Datei? Functions.php? Oder nicht doch lieber eine Art Utility-Plugin?
Good question! To make such functions available for older versions/other variants (what probably will increase their acceptance by plugin developers) they might best be placed in a new include file or a utility plugin. OTOH this might result in an arbitrary accumulation of functions in this "module"---not the best software engineering practice. Nonetheless probably the best we can do for XH 1.x.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply