NAVIGATION
Tag: {SHOW_ARTICLE_CP} ↔ {SHOW_CP}
DisplayS CPs OF articles in listing-mode where you are placing {SHOW_ARTICLE_CP} in your active structure. If you want to show a CP you only have to place {SHOW_CP} into the CP comment field.
A wrapper <div class=“show_article_cp”>OUTPUT</div> is added for a better non text output.
Please do create the class .show_article_cp in your favorite css file if you want.
In case the tag has no output (e.g. in another structure level) we will not produce any crappy formatting splits this way.
- struktur level (article in list-mode) --- 1. article .... list mode but no summary ------ CP Images .... (e.g. output at the right side) A{SHOW_CP} --- 2. article .... list mode with summary ------ CP Text .... (output at the right side) B{SHOW_CP} ------ CP Images .... (output at the right side) C{SHOW_CP} ------ CP Link list ..... --- 3. article .... list mode with summary ------ CP Text/Bild ....
TAG: {SHOW_ARTICLE_CP} for activating/placing this RT within your template
TAG: [X]{SHOW_CP} in the comment field of the displayed CP
Where [X] is the sort criterion e.g. A{SHOW_CP} …. B{SHOW_CP} …. C{SHOW_CP} ….
Place this tag at first in comment field for correct sorting (If you need)
And → CP status: [x] visible (Or change “acontent_visible” in script).
Docu: –
Forum: {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: Changing the sorting criterion (17.01.2010)
Tag: {SHOW_ARTICLE_CP} ↔ {SHOW_CP}
Filename: rt_show_article_cp.php
Filder: template/inc_script/frontend_render/
Condition: → /config/phpwcms/conf.inc.php
Location: /template/inc_script/frontend_render/rt_show_article_cp.php
<?php // ************************************************************************** // 24.04.08 Show CP from an article in list mode (V 1.0) // Knut Heermann (flip-flop) http://planmatrix.de // 25.04.08 Edit by Oliver Georgi // 26.04.08 KH: Output in only active site level doesn´t run // 26.04.08 OG: Optimized source and add manual sorting e.g. // A{SHOW_CP} B{SHOW_CP} C{SHOW_CP} .... // // http://forum.phpwcms.org/viewtopic.php?p=102704#p102704 // http://forum.phpwcms.org/viewtopic.php?p=102798#p102798 // // TAG: {SHOW_ARTICLE_CP} for activating in your template // TAG: [X]{SHOW_CP} in the comment field of the displayed CP // Where [X] is the sort criterion e.g. A{SHOW_CP} B{SHOW_CP} .... // Places this tag first in comment field!!! // // Condition: CP status: [x] visible (Or change "acontent_visible") // Location: Put it into the file e.g.: // /template/inc_script/frontend_render/rt_show_article_cp.php // Switch in conf.inc.php: $phpwcms['allow_ext_render'] = 1; // ************************************************************************** // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- // Nur ausfuehren wenn der Listenmodus eingeschaltet ist // Only run if list mode is true if( $content['list_mode'] == true && strpos($content["all"], '{SHOW_ARTICLE_CP}') !== false ) { $content["all"] = str_replace('{SHOW_ARTICLE_CP}','<div class="show_article_cp">'.my_article_count_cp().'</div>', $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 ''; } ?>
You can turn off the sort order via the comment, and turn on sorting as defined in the structure by changing in
“template/inc_script/frontend_render/rt_show_article_cp.php”
around line 48
from
// CUSTOM INPUT ============================================== // sort order: [true|false] [by comment field | by structure] $sort_by_comment = true; // ===========================================================
to
// CUSTOM INPUT ============================================== // sort order: [true|false] [by comment field | by structure] $sort_by_comment = false; // ===========================================================
Location: /template/inc_script/frontend_render/rt_show_article_cp.php
<?php // ************************************************************************** // 24.04.08 Show CP from an article in list mode (V 1.0) // 17.01.10 Show CP from an article in list mode (V 1.1) // Knut Heermann (flip-flop) http://planmatrix.de // 25.04.08 Edit by Oliver Georgi // 26.04.08 KH: Output in only active site level doesn´t run // 26.04.08 OG: Optimized source and add manual sorting e.g. // A{SHOW_CP} B{SHOW_CP} C{SHOW_CP} .... // 17.01.09 KH: Sort order switch $sort_by_comment // sort order: [true|false] [by comment field | by structure] // // http://forum.phpwcms.org/viewtopic.php?p=102704#p102704 // http://forum.phpwcms.org/viewtopic.php?p=102798#p102798 // // TAG: {SHOW_ARTICLE_CP} for activating in your template // TAG: [X]{SHOW_CP} in the comment field of the displayed CP // Where [X] is the sort criterion e.g. A{SHOW_CP} B{SHOW_CP} .... // Places this tag first in comment field!!! // // Condition: CP status: [x] visible (Or change "acontent_visible") // Location: Put it into the file e.g.: // /template/inc_script/frontend_render/rt_show_article_cp.php // Switch in conf.inc.php: $phpwcms['allow_ext_render'] = 1; // ************************************************************************** // ---------------------------------------------------------------- // obligate check for phpwcms constants if (!defined('PHPWCMS_ROOT')) { die("You Cannot Access This Script Directly, Have a Nice Day."); } // ---------------------------------------------------------------- // Nur ausfuehren wenn der Listenmodus eingeschaltet ist // Only run if list mode is true if( $content['list_mode'] == true && strpos($content["all"], '{SHOW_ARTICLE_CP}') !== false ) { $content["all"] = str_replace('{SHOW_ARTICLE_CP}','<div class="show_article_cp">'.my_article_count_cp().'</div>', $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 ''; } ?>
<note tip>
The basic routine to determine the IDs of all items in a category:
$article = array(); foreach($GLOBALS['content']['articles'] as $value) { $article[] = $value['article_id']; } if(count($article)) { ........
The ID of the current article:
$GLOBALS['aktion'][1];
If the IDs of the CPs of an article are required, they must be read from the DB. CP-IDs are not held in the parent hierarchy, in this case the articles.
The routine for this is shown in the RT.
Interesting for this is the inserted tag {SHOW_CONTENT:….} and/or the function
function showSelectedContent($param='') { ...
in ''/include/inc_front/ext.func.inc.php''.