Viewing phpWcms Code inside Code Contentpart

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
Post Reply
User avatar
jsw_nz
Posts: 907
Joined: Fri 2. Apr 2004, 02:42
Location: New Zealand

Viewing phpWcms Code inside Code Contentpart

Post by jsw_nz »

Just posting this for those interested.

Big thanks TO DeXXus, for bookmarking this hack.

Had a special situation where i plan (in the future) to post/discussOliG's great code - needed the code contentpart NOT to render phpWcms code - so created a hack - this was posted in bug reports (but not a bug)

Need to declare a new array to take care of multiple instances of code contentpart on a give page, so in index.php line 31 add:

Code: Select all

$code_array = array();

Requires a hack to
include/inc_front/content/cnt11.article.inc.php

Code: Select all

<?php 
if (!defined('PHPWCMS_ROOT')) { 
   die("You Cannot Access This Script Directly, Have a Nice Day."); 
} 

$content["code_contentpart"] = "";
$content["code_contentpart"] .= headline($crow["acontent_title"], $crow["acontent_subtitle"], $template_default["article"]); 
if($crow["acontent_text"]) { 
   $crow["acontent_text"] = str_replace(" ", "&nbsp;", html_specialchars($crow["acontent_text"])); 
   $content["code_contentpart"] .= nl2br(div_class($crow["acontent_text"], $template_default["article"]["code_class"])); 
} 
array_push($code_array, $content["code_contentpart"]);
$code_integer = count($code_array) - 1;
$CNT_TMP .="[show_code:".$code_integer."]";
?>




and at end of content.func.inc.php
(rather than using inc_script/frontend_render directory)

Code: Select all

 
function get_code_contentpart($position){
	global $code_array;
	$temp_content = $code_array[$position];
	return $temp_content;
}
 // CODE CONTENT_PART REPLACEMENT 
 if( ! (strpos($content["all"],'[show_code')===false)) {
	$content["all"] = preg_replace('/\[show_code:(\d+)\]/e','get_code_contentpart("$1");',$content["all"]); 
 }


here is the original thead (now in a discontinued section of forum)
http://www.phpwcms.de/forum/viewtopic.php?t=12036


cheers,
-j-
Post Reply