{{indexmenu_n>500}} ====== SHOW_ARTICLE_CP ====== Gibt die CPs der Artikel die sich in der aktiven Struktur befinden an der Stelle **{SHOW_ARTICLE_CP}** im Template aus. (Nur im Artikel Listen-Modus verfügbar). Wenn ein CP ausgegeben werden soll wird der Tag **{SHOW_CP}** in das CP Kommentarfeld eingefügt. Der Tag **{SHOW_ARTICLE_CP}** legt fest, wo die CPs in der Vorlage angezeigt werden sollen. Es werden nur die CPs der Artikel in der aktuellen Ebene ausgegeben. \\ ---- ---- Docu: -- \\ Forum: [[http://forum.phpwcms.org/viewtopic.php?f=8&t=17082|{SHOW_ARTICLE_CP} <-> {SHOW_CP}]] **Autor:** K.Heermann (flip-flop) http://planmatrix.de / O.Georgi http://phpwcms.de \\ **CMS Version:** >= 1.3 \\ **Version:** V1.0 \\ Update: V1.1: Wechseln des Sortierkriteriums //(17.01.2010)// Tag: **{SHOW_ARTICLE_CP} <-> {SHOW_CP}** Dateiname: **rt_show_article_cp.php** \\ Verzeichnis: ** template/inc_script/frontend_render/ ** **Bedingung:** -> [[http://www.phpwcms-docu.de/config_dateien.phtml|/config/phpwcms/conf.inc.php]] \\ * ##$phpwcms['allow_ext_render'] = 1;## ---- ---- \\ - struktur level (Artikel im Listen-Modus) --- 1. article .... Listen-Modus aber kein Schlagtext (summary) ------ CP Images .... (Z.B. Ausgabe an der rechten Seite) A{SHOW_CP} --- 2. article .... Listen-Modus mit Schlagtext ------ CP Text .... (Ausgabe an der rechten Seite) B{SHOW_CP} ------ CP Images .... (Ausgabe an der rechten Seite) C{SHOW_CP} ------ CP Link list ..... --- 3. article .... Listen-Modus mit Schlagtext ------ CP Text/Bild .... \\ TAG: **{SHOW_ARTICLE_CP}** um den RT zu aktivieren und den Ort der Ausgabe in der Vorlage zu bestimmen. TAG: **[X]{SHOW_CP}** im Kommentarfeld des anzuzeigenden CPs. Wobei **[X]** das Sortierkriterium ist, z.B. **A{SHOW_CP}** ....**B{SHOW_CP}** .... **C{SHOW_CP}** .... :!: Platziere diesen Tag als ersten Eintrag in das Kommentarfeld wenn eine korrekte Sortierung verlangt wird :!: Und -> CP Status: [x] sichtbar (Oder ändere im Skript "acontent_visible" für die Darstellung unsichtbarer CPs). Es wird autoamtisch ein Wrapper //**
**OUTPUT**
**// erzeugt. \\ Bitte lege die Klasse //class **.show_article_cp**// in einer eingebundenen CSS Datei an wenn benötigt.\\ Sinn: Wenn der Tag keine Ausgabe erzeugt (z.B. in einem anderen Strukturlevel) wird kein überflüssiger Quelltext erzeugt der u.U. die Formatierung der Seite sprengt. ---- ---- \\ ===== Code V1.0: ===== Location: **template/inc_script/frontend_render/rt_show_article_cp.php** '.my_article_count_cp().'', $content["all"]); } else { $content["all"] = str_replace('{SHOW_ARTICLE_CP}', '', $content["all"]); } function my_article_count_cp() { // Artikel der aktuellen Seitenebene holen // get current listed article IDs $article = array(); foreach($GLOBALS['content']['articles'] as $value) { $article[] = $value['article_id']; } if(count($article)) { // Artikel in der DB suchen und CP-ID bereitstellen // Search for the article and make the CP-ID available $sql = "SELECT acontent_id "; $sql .= "FROM ".DB_PREPEND."phpwcms_articlecontent "; $sql .= "WHERE acontent_visible=1 AND acontent_trash=0 "; $sql .= 'AND acontent_aid IN ('.implode(',', $article).') '; $sql .= "AND acontent_comment LIKE '%{SHOW_CP}%' "; // SORTING ORDER: sort by comment = "acontent_comment" | sort by id = "article_aid" | sort by structure = "acontent_sorting" $sql .= "ORDER BY acontent_comment"; // acontent_comment, article_aid, acontent_sorting $result = _dbQuery($sql); if(isset($result[0]['acontent_id'])) { // Any result available? // CP-ID String fuer SHOW_CONTENT bereitstellen // Create CP-IDs string for SHOW_CONTENT $cp_my_id_str = ''; foreach($result as $value) { $cp_my_id_str .= ','.$value['acontent_id']; } // Ausgabe der betroffenen CPs mit SHOW_CONTENT // Make the encountered CPs available with SHOW_CONTENT return showSelectedContent('CP'.$cp_my_id_str); } } return ''; } ?> ~~UP~~ ====== Update v1.1: Wechseln des Sortierkriteriums ====== Die Sortierung durch den Kommentar kann abgeschaltet und die Sortierung wie in der Struktur vorgegeben eingeschaltet werden: In der Datei \\ "template/inc_script/frontend_render/rt_show_article_cp.php" \\ etwa ab Zeile 48 \\ von // CUSTOM INPUT ============================================== // sort order: [true|false] [by comment field | by structure] $sort_by_comment = true; // =========================================================== nach // CUSTOM INPUT ============================================== // sort order: [true|false] [by comment field | by structure] $sort_by_comment = false; // =========================================================== geändert wird. \\ ===== Code V1.1 ===== Location: **template/inc_script/frontend_render/rt_show_article_cp.php** '.my_article_count_cp().'', $content["all"]); } else { $content["all"] = str_replace('{SHOW_ARTICLE_CP}', '', $content["all"]); } function my_article_count_cp() { // CUSTOM INPUT ============================================== // sort order: [true|false] [by comment field | by structure] $sort_by_comment = true; // =========================================================== // Artikel der aktuellen Seitenebene holen // get current listed article IDs $article = array(); foreach($GLOBALS['content']['articles'] as $value) { // $article[$value['article_sort']] = $value['article_id']; $article[] = $value['article_id']; } if(count($article)) { // Artikel in der DB suchen und CP-ID bereitstellen // Search for the article and make the CP-ID available $sql = "SELECT acontent_id, acontent_aid "; $sql .= "FROM ".DB_PREPEND."phpwcms_articlecontent "; $sql .= "WHERE acontent_visible=1 AND acontent_trash=0 "; $sql .= 'AND acontent_aid IN ('.implode(',', $article).') '; $sql .= "AND acontent_comment LIKE '%{SHOW_CP}%' "; // SORTING ORDER: sort by comment = "acontent_comment" | sort by id = "article_aid" | sort by structure = "acontent_sorting" $sql .= ($sort_by_comment) ? "ORDER BY acontent_comment" : "ORDER BY acontent_sorting"; //,acontent_comment, article_aid, acontent_sorting $result = _dbQuery($sql); if(isset($result[0]['acontent_id'])) { // Any result available? // CP-ID String fuer SHOW_CONTENT bereitstellen // Create CP-IDs string for SHOW_CONTENT $cp_my_id_str = ''; if ($sort_by_comment) { // sort by comment? foreach($result as $value) { $cp_my_id_str .= ','.$value['acontent_id']; } } else { // sort by structure foreach($article as $value1) { // The article sort order by structure foreach($result as $value2) { // CP sort order by structure if ($value2['acontent_aid'] == $value1) // CP in article? $cp_my_id_str .= ','.$value2['acontent_id']; } } } // Ausgabe der betroffenen CPs mit SHOW_CONTENT // Make the encountered CPs available with SHOW_CONTENT return showSelectedContent('CP'.$cp_my_id_str); } } return ''; } ?> ~~UP~~ \\ ===== Für Programmierer: ===== **Die Basisroutine um die IDs aller Artikel einer Kategorie zu bestimmen:** $article = array(); foreach($GLOBALS['content']['articles'] as $value) { $article[] = $value['article_id']; } if(count($article)) { ........ \\ **Die ID des aktuellen Artikels:** $GLOBALS['aktion'][1]; \\ Wenn die IDs der CPs eines Artikels verlangt werden, müssen diese aus der DB ausgelesen werden. CP-IDs werden nicht in der übergeordneten Hierarchie, in diesem Fall den Artikeln, festgehalten. \\ Die Routine dazu ist im RT abgebildet. Interessant hierzu ist der eingebaute TAG {SHOW_CONTENT:....} bzw. die Funktion function showSelectedContent($param='') { ... in %%''/include/inc_front/ext.func.inc.php''%%.