Page 1 of 2

{SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Fri 25. Apr 2008, 18:50
by flip-flop
Display CPs from articles in listing-mode at the place {SHOW_ARTICLE_CP} in your active structure.
If you want to show a CP you only must write {SHOW_CP} in the CP comment field.
- (Short german description).
-----------------------------------------------------------------
- struktur level (article in list-mode)
--- 1. article .... list mode but no summary
------ CP Images .... (e.g. output at the right side)
--- 2. article .... list mode with summary
------ CP Text .... (output at the right side)
------ CP Images .... (output at the right side)
------ CP Link list .....
--- 3. article .... list mode with summary
------ CP Text/Bild ....
-----------------------------------------------------------------

TAG: {SHOW_ARTICLE_CP} for activating/placing this rt 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} ....
Place this tag first in comment field for correctly sorting (If you need)!!!

And -> CP status: [x] visible (Or change it in the script).

/template/inc_script/frontend_render/rt_show_article_cp.php

Code: Select all

<?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}%' ";  
		$sql .= "ORDER BY 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 '';
}

?>
# 25.04.08 Add : Wrapper <div class="show_article_cp">OUTPUT</div>
Please create the class .show_article_cp in your favor css file if you want.
If the tag has no output (e.g. in an other structure level) so we haven´t any crappy formatting splits.
# 26.04.08 Correction: The "only output" in active level dont´t work. (K.H.)
# 26.04.08 Add: Optimized source and add manual sorting e.g. A{SHOW_CP} B{SHOW_CP} C{SHOW_CP} .... (O.G.)
Please put the Tag e.g. A{SHOW_CP} first in the comment field

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Fri 25. Apr 2008, 21:20
by juergen
*clap clap*

Hey Knut, that is a very usefull thing,,genious.. ;)

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Sat 26. Apr 2008, 16:03
by flip-flop
Updated the tag:

# 26.04.08 Correction: The "only output" in active level dont´t work. (KH)
# 26.04.08 Add: Optimized source and add manual sorting e.g. A{SHOW_CP} B{SHOW_CP} C{SHOW_CP} .... (OG)
Please put the Tag e.g. A{SHOW_CP} first in the comment field

Very great stuff - the technical optimizing by O.G. :D

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Tue 8. Jul 2008, 22:10
by planetsuhl
Hey... This RT is truly that one i need for my next page. I have installed everything as you explained it.

1. created /template/inc_script/frontend_render/rt_show_article_cp.php with your code

2. wrote the RT {SHOW_ARTICLE_CP} in my right field in the Templat (VORLAGE) {RIGHT}

3. wrote A{SHOW_CP} in the Notiz /comment field of the CP

But it won´t work!... Any further explanation?

The page: http://s207173281.online.de/leobloom/index.php?News

Thx

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Tue 8. Jul 2008, 23:10
by flip-flop
Hi,

is there any CP (ContentPart) in your articles?

And please in your config set:
$phpwcms['allow_ext_render'] = 1; //allow including of custom external scripts at frontend rendering

Knut

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Wed 9. Jul 2008, 09:41
by planetsuhl
Yes, I did the config change:
$phpwcms['allow_ext_render'] = 1; //allow including of custom external scripts at frontend

In my "standard Vorlage" -> I Included this Code at the {RIGHT} field

Code: Select all

<div style="padding: 5px 5px 5px 5px; margin:0;" class="rechteSeite">{RIGHT}{SHOW_ARTICLE_CP}</div>
Image

My Article Structur & CP look like:

All 3 Articles are declared as Article LIst.
The Test Article has no sumary text included. The others have. I´ld like to show the CP of the Test Article on the right side, during the list of the other two Article is listed at the left side!

Image
Image

An at the "Notiz" field in my CP of the article Test - there is the A{SHOW_CP} RT.
Image

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Wed 9. Jul 2008, 18:36
by flip-flop
Mhh, there is no problem for me with this RT.
The output of the marked CPs is generated only in the structure level where they are is active.

What is your cms version?

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Thu 10. Jul 2008, 09:50
by planetsuhl
Die Version 1.3.3 (2007/05/02).

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Sun 24. Aug 2008, 12:54
by yoshi001
ist es möglich mit diesem RT auch einzelne elemente der contentparts anzusprechen, bzw. abzufangen?
ideal wäre, {CPID} und {TITLE} ausgegeben zu bekommen, um aus diesen dann eine <ul> zu formen.

dann könnte ich dynamisch einen schicken 'coda-slide' hinbekommen: http://jqueryfordesigners.com/demo/coda-slider.html

gruss,
yoshi

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Sun 24. Aug 2008, 13:02
by Jensensen
Hi yoshi,

schau mal hier:
[x]

ggf. hilft das weiter?

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Sun 24. Aug 2008, 17:24
by yoshi001
nun ja - jetzt ist's wohl zeit für mein coming-out als reiner frontend-mann.

wenn ich flip-flops skript richtig interpretiere, holt es sämtliche (sichtbaren, ungelöschten und mit "SHOW_CP" kommentierten)
CP's aus "phpwcms_articlecontent" und behält sie in "$result". dann kommt die "cp_my_id_str"-geschichte, bei der ich schon aussteige.

ich würde aus "$result" gerne lediglich "$data['acontent_id']" und "$data['acontent_title']" holen
und dann in zeile 34 z.b. als <li id="acontent_id"><a href="#title"></li> ausgeben.

und wenn ich den "CP trigger" richtig verstehe, ermöglicht mir das im prinzip das selbe - wenn ich z.b. alle CP's aus der datenbank lese und via funktion dann eben das mache, was ich beschrieben habe - wenn ich php sprechen würde. allerdings verstehe ich das frontend_init/frontend_render-ding nicht - bzw. was der unterschied zwischen einem programmierten RP (für gewöhnlich in frontend_render) und einem CP trigger (zwingend in frontend_init?)

<offtopic>
die quintessenz:
- ich kann nicht programmieren
- weide mich an der programmierleistung anderer, um meine ideen umzusetzen
- kann hier und da mal ein paar zeilen umbiegen.. scheitere aber hier
- und frage unverfrorenderweise nach einer lösung (ja, ich schäme mich ein bisschen)..

fragen kostet schliesslich nichts - und sollte mir jemand unter die arme greifen und das klappen, finde ich das ein ziemlich sexy feature (siehe link oben).
ist natürlich auch zurechtgebogen und nicht 100% bordmittel, aber mann kann es einfachen redakteuren zumuten weil dynamisch.
</offtopic>

hmm, mir raucht schon der kopf heute..

trotzdem dank & gruss,
yoshi

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Sun 24. Aug 2008, 17:27
by yoshi001
<edit>
sinnlos-post - gelöscht
</edit>

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Sun 24. Aug 2008, 22:22
by yoshi001
evtl mag sich aber doch jemand erbarmen?

mittlerweile bin ich soweit, dass ich die gewünschten inhalte ("acontent_id', "acontent_title") augelesen bekomme:

Code: Select 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, acontent_title ";
          $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}%' "; 
          $sql .= "ORDER BY acontent_comment"; //, article_aid, acontent_sorting
          
          $result = _dbQuery($sql);
          
          //dumpVar($result);
          
		if(isset($result[0]['acontent_id'])) {
		
			foreach ($result as $value) {
			
				//dumpVar($value);
				//wie weiter hier?
			}
			
			return (); //und hier?
			
		}
ergo bekomme ich in der foreach-schleife jeweils ein mehrdimensionales array mit den von mir gewünschten inhalten eines contentparts (in diesem falle 4 stück) - damit ich den überblick behalte, die "dumpVar's":

Code: Select all

Array
(
    [acontent_id] => 2
    [acontent_title] => abschnittstitel1
)

Array
(
    [acontent_id] => 3
    [acontent_title] => abschnittstitel2
)

Array
(
    [acontent_id] => 13
    [acontent_title] => abschnittstitel3
)

Array
(
    [acontent_id] => 14
    [acontent_title] => abschnittstitel4
)

wenn ich in der schleife via "print" die arrays ausgebe, bekomme ich, was ich brauche.
was ich nicht hinbekomme ist, das jeweilige array, bzw. dessen inhalte auseinanderdividiert an die funktion zurückzugeben.

kann mir dabei evtl. jemand auf die sprünge helfen?
oder auch nur schelte, weil ich aus unwissenheit totalen quark fabriziere - wär' auch schon mal was..


dank+gruss,
yoshi

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Mon 25. Aug 2008, 07:14
by juergen
Hai,

return $das_ist_das_gesamte_frontendwerk;

und vorher :

foreach $dings as $bums {

$das_ist_das_gesamte_frontendwerk . ='.....';
Bläst du die Variable über die Schleife mit deinen Inhalten, Tags auf

...

und gibst sie an die Variable die noch gerendert werden wird $content['all'] zurück. Das ganze ist ja nur ein Replacer.. Damit geht alles, einfach alles .. ;)

Re: {SHOW_ARTICLE_CP} <-> {SHOW_CP}

Posted: Mon 25. Aug 2008, 07:40
by yoshi001
guten morgen df6ih,

und vielen dank.
das hatte ich mir im skript-ursprung von flip-flop schon so abgeguckt und auch versucht; eben wieder, mit folgendem output:
PHP Parse error: syntax error, unexpected '=' (..) on line 75
passiert bei:

Code: Select all

// Artikel in der DB suchen und CP-ID bereitstellen
          // Search for the article and make the CP-ID available
          $sql  = "SELECT acontent_id, acontent_title ";
          $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}%' "; 
          $sql .= "ORDER BY acontent_comment"; //, article_aid, acontent_sorting
          
          $result = _dbQuery($sql);
          
          // echo
          //dumpVar($result);
          
		if(isset($result[0]['acontent_id'])) {
		
			foreach ($result as $value) {
				
				$foo . = '<li class=""><a href="#'$value['acontent_id']'">'$value['acontent_title']'</a></li>'; //line 75
				
			}
			
			return $foo;
			
		}