NAVIGATION
This is an old revision of the document!
Systeminterne Linkdarstellung von Kategorie, Artikel, Print.
Diese Darstellung kann aktiv eingesetzt werden als Link oder als Abfrage des Iststatus dienen.
0 = structure ID 1 = article ID 2 = z.B. wenn 1 dann Print 3 = wenn 1 dann zeig(e/t) Kategorie 4 = wenn 1 dann Link zu Artikel 5 = freie Nutzung
Bereitgestellt in: /include/inc_front/content.func.inc.php
$aktion = array(0,0,0,0,1,0);
$aktion = explode(',', $_GET["id"], 6); $aktion[0] = intval($aktion[0]); //$aktion[0] will be always available // structure ID $aktion[1] = isset($aktion[1]) ? intval($aktion[1]) : 0; // article ID $aktion[2] = isset($aktion[2]) ? intval($aktion[2]) : 0; // z.B. wenn 1 dann Print $aktion[3] = isset($aktion[3]) ? intval($aktion[3]) : 1; // wenn 1 dann zeige cat $aktion[4] = isset($aktion[4]) ? intval($aktion[4]) : 0; // wenn Link zu article zeige (1) $aktion[5] = isset($aktion[5]) ? intval($aktion[5]) : 0; // freie Nutzung
Zugriff mit $GLOBALS['aktion']
Die Kategorie ID:
echo 'Cat-ID: '.$GLOBALS['aktion']['0'];
Die Artikel ID (Ausgabe nur im Artikeldetail):
echo 'Cat-ID: '.$GLOBALS['aktion']['1'];
Befinden wir uns in der Kategorieansicht? [1=Ja|0=Nein]
echo 'Cat-ID: '.$GLOBALS['aktion']['3'];
Befinden wir uns im Artikeldetail? [1=Ja|0=Nein]:
echo 'Cat-ID: '.$GLOBALS['aktion']['4'];
Annahme: Eine Kategorie (ID=7) arbeitet im einfachen Artikelmodus (ID=26) (Anzahl an Top-Artikeln: -1, oder wenn Anzahl an Top-Artikeln: > 1 und Artikelanzahl = 1)
[0] => 7 // Kategorie-ID
[1] => 26 // Artikel-ID
[2] => 0
[3] => 1 // Kategorieansicht
[4] => 1 // Artikel-Detailansicht
[5] => 0
Als Link: index.php?id=7,26,0,1,1,0 oder der direkte Artikellinkindex.php?aid=26
Annahme: Eine Kategorie (ID=2) arbeitet im Artikellistenmodus (ID=26,6,5,3) (Anzahl an Top-Artikeln: > 1, Artikelanzahl > 1)
[0] => 2 // Kategorie-ID
[1] => 0
[2] => 0
[3] => 1 // Kategorieansicht
[4] => 0
[5] => 0
Als Link: index.php?id=2,0,0,1,0,0
[0] => 2 // Kategorie-ID
[1] => 6 // Artikel-ID
[2] => 0
[3] => 0
[4] => 1 // Artikel-Detailansicht
[5] => 0
Als Link: index.php?id=2,6,0,0,1,0 oder der direkte Artikellinkindex.php?aid=6
Die wichtigsten internen Variablen:
Bedingung: $phpwcms['allow_cntPHP_rt'] = 1; //allow PHP replacement tags and includes in content parts
<!-- Var Dump =================== //--> [PHP] echo '<pre>LEVEL ID</pre>'; dumpVar($GLOBALS['LEVEL_ID']); echo '<pre>LEVEL KEY</pre>'; dumpVar($GLOBALS['LEVEL_KEY']); echo '<pre>LEVEL STRUCT</pre>'; dumpVar($GLOBALS['LEVEL_STRUCT']); echo '====================== <br /> '; dumpVar($GLOBALS['content']["articles"]); // Artikel-Struktur dumpVar($GLOBALS['content']["struct"]); // Ebenen-Struktur // article list mode: Wenn mwhr als ein Artikel verfuegbar und in der Seitenstruktur -> Kategorie -> Anzahl an Top-Artikeln: > 1 dumpVar($GLOBALS['content']["list_mode"]); // (true|false) // Anzahl an Top-Artikeln fuer den Artikellistenmodus in der Seitenstruktur -> Kategorie -> Anzahl an Top-Artikeln: dumpVar($GLOBALS['content']['struct'][$content['cat_id']]['acat_topcount']; // (Zaehler) [/PHP] <!-- ====================== //-->
Ausgabemöglichkeiten mit der Funktion dumpVar($var); Bsp.:
$_test = array ('22','phpwcms','37');
dumpVar($_test);
Array ( [0] => 22 [1] => phpwcms [2] => 37 )
HTML Code:
<pre>Array ( [0] => 22 [1] => 23 [2] => 37 [3] => 39 [4] => 38 [5] => 41 ) </pre>
dumpVar($_test,1);
<!--
Array
(
[0] => 22
[1] => phpwcms
[2] => 37
)
//-->
$_my_dump = dumpVar($_test,2);
Zuweisung der Ausgabe wie dumpVar($_test); an eine Variable.
Die Variable $content['all_keywords'] oder $GLOBALS['content']['all_keywords'] wenn in Funktionen verwendet, liefert die Keywords von gerade anzuzeigenden Artikel.
Bsp.: Forum Css eines Artikels ändern
Eine spezielle CSS Formatierung für einen Artikel:
Frage:
“Wenn ich für einen einzigen Artikel ein spezielles css angeben möchte, wo mache ich das?
Zur Erklärung, ich möchte einzelne Artikel mit einem dunklen statt einem hellen Seitenhintergrund haben.”
Antwort:
“Ich würde mit einem speziellen Keyword arbeiten und mittels Frontend Render dann entsprechend darauf reagieren.
Keyword “*CSS-dark*” beim Artikel ins entsprechende Feld setzen. Beim Rendering wird darauf geprüft und <body> Tag erhält die entsprechende Klasse. Das kann dann normaler per CSS definiert werden.”
frontend_init
if(strpos($content['all_keywords'], '*CSS-dark*')!== false) { $template_default['body']['class'] = 'dark level-'; $content['all_keywords'] = str_replace('*CSS-dark*', '', $content['all_keywords']); } ?>
CSS:
body.dark { background-color: #666666; }
Achtung - die Klasse(n) “dark level-” wurde bewußt so gewählt, da immer noch zusätzlich die Level ID mitgegeben wird.
Update 25.06.2009: Revision: r317
Es kann nun direkt die aktuelle Kategorie-ID bezogen auf das Level ausgelesen werden.
<div style="font-size:10px;"><br> <b>Old Level-Ids:</b><br> ---------------------------<br> [PHP] // Old Level-Ids echo ( (isset($GLOBALS['LEVEL_ID'][1])) ? ( 'Level 1 ID='. $GLOBALS['LEVEL_ID'][1]) : 'no level 1' ) . '<br \/>'; echo ( (isset($GLOBALS['LEVEL_ID'][2])) ? ( 'Level 2 ID='. $GLOBALS['LEVEL_ID'][2]) : 'no level 2' ) . '<br \/>'; echo ( (isset($GLOBALS['LEVEL_ID'][3])) ? ( 'Level 3 ID='. $GLOBALS['LEVEL_ID'][3]) : 'no level 3' ) . '<br \/>'; echo ( (isset($GLOBALS['LEVEL_ID'][4])) ? ( 'Level 4 ID='. $GLOBALS['LEVEL_ID'][4]) : 'no level 4' ) . '<br \/>'; [/PHP] <br> <b>New Level-Ids (since r317):</b><br> ---------------------------<br> {LEVEL1_ID:} {LEVEL1_ID} <br> {LEVEL2_ID:} {LEVEL2_ID} <br> {LEVEL3_ID:} {LEVEL3_ID} <br> {LEVEL4_ID:} {LEVEL4_ID} <br> ---------------------------<br> <!-- =================== //--> </div> <!-- end font-size //-->
Aktuelle Nr. der Ebene / Aktueller Kategorie-Alias / Aktuelle Kategorie-ID
Autor: K.Heermann (flip-flop) http://planmatrix.de 2009/05/14
CMS-Version: >= V1.2.7
Tag: {LEVCATID}
Datei: template/inc_script/frontend_render/rt_levcatid.php
Bedingung: → /config/phpwcms/conf.inc.php
<?php // ---------------------------------------------------------------- // OBLIGATE CHECK FOR PHPWCMS CONSTANTS if (!defined('PHPWCMS_ROOT')) {die("You Cannot Access This Script Directly, Have a Nice Day.");} // ---------------------------------------------------------------- // FE Ausgabe {LEVCATID}: Aktuelle Nr. der Ebene / Aktueller Kategorie-Alias / Aktuelle Kategorie-ID function LEV_CAT_ID () { $level = 0; for ($i = 0; $i <= $level; $i++) { // Wieviele Level sind vorhanden? isset($GLOBALS['LEVEL_ID'][$i]) ? $level++ : $level--; } // Aktuellen Kategorie-alias und ID auslesen $cat_alias = $GLOBALS['content']["struct"][$GLOBALS['content']["cat_id"]]["acat_alias"]; $cat_id = $GLOBALS['content']['cat_id']; // ======= Ende Testsektion return '[LEVEL='.$level.' | CAT='.$cat_alias.' | ID='.$cat_id.']'.LF; } $content['all'] = str_replace('{LEVCATID}', '<span style="color:green; font-size:10px; font-weight:bold;">'.LEV_CAT_ID().'</span>', $content['all']); ?>
Siehe zu Variablen auch Standard Tags zusammengefasst
Beispiel: Die Variable wird “cpimage” genannt und beinhaltet einen Integer-Wert.
$site = $GLOBALS['phpwcms']['site'].$GLOBALS['phpwcms']['root']; $cat_alias = $GLOBALS['content']["struct"][$GLOBALS['content']["cat_id"]]["acat_alias"]; $href_str = $site.'index.php?'.$cat_alias; $get_str = 'cpimage=';
z.B. http://my_site.tld/index.php?active_category&cpimage=34
$my_number = 34; $my_complete_link = $href_str.'&'.$get_str.$my_number; // http://my_site.tld/index.php?active_category&cpimage=34
// Is there a GET var? if (isset($GLOBALS['_getVar']['cpimage'])) { $GLOBALS['_getVar']['cpimage'] = intval($GLOBALS['_getVar']['cpimage']); // Convert to integer $cpImgNr = $GLOBALS['_getVar']['cpimage']; } else $cpImgNr = false; // if there is no GET var set it to false
Der Integerwert in $cpImgNr kann nun verarbeitet werden, bzw. sollte vorher auf “false” geprüft werden.
Normalerweise sind diese Felder nicht mehr brauchbar, da diese bei der Layoutvariante Block: “Eigene” nicht abgefragt werden.
Mit einem kleinen Ersetzer ist es jedoch möglich diese Eingabefelder im Feld “Haupt” einzubinden.
An den Stellen an denen der Inhalt dieser Felder in das Template eingebunden werden soll, werden Tags in “Haupt:” gesetzt.
<note> Es kann u.U. passieren, dass einige Funktionen in den alternativen Felder vor dem Einfügen in “Haupt:” von System abgearbeitet werden, dann müssen diese Anweisungen Direkt in “Haupt:” platziert werden. Alternativ könnte der RT {SHOW_CONTENT:…..} verwendet werden. </note>
Bedingung: → /config/phpwcms/conf.inc.php
In dem Verzeichnis template/inc_script/frontend_init/ wird die Datei template_inject.php mit folgendem Inhalt abgelegt:
<?php /********************************************************************************************* * Backend Template field replacer * Replaces the placeholder {HEADERTEMP}, {FOOTERTEMP}, {LEFTTEMP}, {RIGHTTEMP} in "main" * with the contents of the fields "header", "footer", "left", "right". * KH 07.01.2010 **********************************************************************************************/ // ------------------------------------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ------------------------------------------------------------------------------------------- if (!empty($block['headertext']) ) $block['maintext'] = str_replace('{HEADERTEMP}', $block['headertext'],$block['maintext']); if (!empty($block['righttext'])) $block['maintext'] = str_replace('{RIGHTTEMP}' , $block['righttext'], $block['maintext']); if (!empty($block['footertext'])) $block['maintext'] = str_replace('{FOOTERTEMP}', $block['footertext'],$block['maintext']); if (!empty($block['lefttext'])) $block['maintext'] = str_replace('{LEFTTEMP}' , $block['lefttext'], $block['maintext']); ?>
<note important> Um die Abfrage schnell zu halten wird nicht gegen ein Vorhandensein der Tags im “Haupt:” geprüft. Daher liegt es in Ihrer Verantwortung hier nur Tags zu setzen, wenn auch entsprechender Content in den alternativen Feldern vorhanden ist. </note>