{GT} and custom replacement tags

Use GitHub to post bug reports and error descriptions for phpwcms. Describe your problem detailed!
Locked
consistency
Posts: 40
Joined: Sat 5. Mar 2005, 23:59

{GT} and custom replacement tags

Post by consistency »

hi all

while writeing a question post about the gt used by custom tag, i found the soluton for the problem/bug

i wanted to create gt menus with custom tags, but this dont work because the gt mod is called before
the included custom files.

include\inc_front\content.func.inc.php

the {GT} part has to be moved after the custom function part

Code: Select all

// -------------------------------------------------------------

// Jérôme's Graphical Text MOD
// Coypright (C) 2004 by 
if($phpwcms["gt_mod"]) { //enabled/disable GT MOD
	require_once ('include/inc_module/mod_graphical_text/inc_front/gt.func.inc.php');
}

// -------------------------------------------------------------

// -------------------------------------------------------------

// add possible redirection code (article summary) to $block["htmlhead"];
$block["htmlhead"]  = render_PHPcode($block["htmlhead"]);
$block["htmlhead"]  = $content["redirect"]["code"].$block["htmlhead"]."\n";
$block["htmlhead"] .= '<meta name="generator" content="phpwcms v'.$phpwcms['version']."\">\n";
// insert description meta tag if not definied
if(!stristr($block["htmlhead"], '"description"') && $content["struct"][$aktion[0]]["acat_info"]) {
	$block["htmlhead"] .= '<meta name="description" content="';
	$block["htmlhead"] .= html_specialchars($content["struct"][$aktion[0]]["acat_info"])."\">\n";
}
// insert keywords meta tag if not definied
//if(!stristr($block["htmlhead"], '"keywords"') && !empty($content["articles"][$aktion[1]]["article_keyword"])) {
if(!stristr($block["htmlhead"], '"keywords"') && !empty($content['all_keywords'])) {
	$content['all_keywords'] = explode (",", $content['all_keywords']);
	$content['all_keywords'] = array_map('trim', $content['all_keywords']);
	$content['all_keywords'] = array_diff($content['all_keywords'], array(''));
	$content['all_keywords'] = array_unique($content['all_keywords']);
	$block["htmlhead"] .= '<meta name="keywords" content="';
	$block["htmlhead"] .= html_specialchars(implode(', ', $content['all_keywords']))."\">\n";
}

// -------------------------------------------------------------

// if you want to use the Coppermine slideshow hack
// {SLIDESHOW:ID}
//include('sample_ext_php/slideshow.php');

// -------------------------------------------------------------

// try to include custom functions and replacement tags or what you want to do at this point of the script
// default dir: "phpwcms_template/inc_script/frontend_render"; only *.php files are allowed there
if($phpwcms["allow_ext_render"]) {
	if(count($custom_includes = get_tmpl_files(PHPWCMS_TEMPLATE.'inc_script/frontend_render', 'php'))) {
		foreach($custom_includes as $value) {
			include_once(PHPWCMS_TEMPLATE.'inc_script/frontend_render/'.$value);
		}
	}
}

so that custom tags can use {GT} functions

should look like that afterwards

Code: Select all


// -------------------------------------------------------------

// -------------------------------------------------------------

// add possible redirection code (article summary) to $block["htmlhead"];
$block["htmlhead"]  = render_PHPcode($block["htmlhead"]);
$block["htmlhead"]  = $content["redirect"]["code"].$block["htmlhead"]."\n";
$block["htmlhead"] .= '<meta name="generator" content="phpwcms v'.$phpwcms['version']."\">\n";
// insert description meta tag if not definied
if(!stristr($block["htmlhead"], '"description"') && $content["struct"][$aktion[0]]["acat_info"]) {
	$block["htmlhead"] .= '<meta name="description" content="';
	$block["htmlhead"] .= html_specialchars($content["struct"][$aktion[0]]["acat_info"])."\">\n";
}
// insert keywords meta tag if not definied
//if(!stristr($block["htmlhead"], '"keywords"') && !empty($content["articles"][$aktion[1]]["article_keyword"])) {
if(!stristr($block["htmlhead"], '"keywords"') && !empty($content['all_keywords'])) {
	$content['all_keywords'] = explode (",", $content['all_keywords']);
	$content['all_keywords'] = array_map('trim', $content['all_keywords']);
	$content['all_keywords'] = array_diff($content['all_keywords'], array(''));
	$content['all_keywords'] = array_unique($content['all_keywords']);
	$block["htmlhead"] .= '<meta name="keywords" content="';
	$block["htmlhead"] .= html_specialchars(implode(', ', $content['all_keywords']))."\">\n";
}

// -------------------------------------------------------------

// if you want to use the Coppermine slideshow hack
// {SLIDESHOW:ID}
//include('sample_ext_php/slideshow.php');

// -------------------------------------------------------------

// try to include custom functions and replacement tags or what you want to do at this point of the script
// default dir: "phpwcms_template/inc_script/frontend_render"; only *.php files are allowed there
if($phpwcms["allow_ext_render"]) {
	if(count($custom_includes = get_tmpl_files(PHPWCMS_TEMPLATE.'inc_script/frontend_render', 'php'))) {
		foreach($custom_includes as $value) {
			include_once(PHPWCMS_TEMPLATE.'inc_script/frontend_render/'.$value);
		}
	}
}

// -------------------------------------------------------------

// Jérôme's Graphical Text MOD
// Coypright (C) 2004 by 
if($phpwcms["gt_mod"]) { //enabled/disable GT MOD
	require_once ('include/inc_module/mod_graphical_text/inc_front/gt.func.inc.php');
}

but i dont know if this makes any other problem because of loading after the "redirection" stuff.
maybe oliver can tell.
if the change makes no problem, maybe oliver can change it so that it works for all.

after the change the following will work

"phpwcms_template\inc_script\frontend_render\sublevelnav.php"

Code: Select all

if( ! ( strpos($content["all"],'{MY_NAV_ROW')===false ) ) {
	$GLOBALS['template_default']["nav_row"]["link_direct_before"]			= '{GT:menu}';
	$GLOBALS['template_default']["nav_row"]["link_direct_after"]			= '{/GT}';
	$GLOBALS['template_default']["nav_row"]["link_direct_before_active"]	= '{GT:menu}';
	$GLOBALS['template_default']["nav_row"]["link_direct_after_active"]	= '{/GT}';
	$content["all"] = str_replace('{MY_NAV_ROW}', nav_level_row(0), $content["all"]);
	$content["all"] = preg_replace('/\{MY_NAV_ROW:(\w+|\d+):(0|1)\}/e',"nav_level_row('$1',$2);",$content["all"]);
}
just an idea: if you missuse the "phpwcms_template\inc_script\frontend_init\youfile.php" it should also work, because it it called before gt. (havenot tested this)

greets


This post was lovingly crafted with Pawsoft Fass, the (F)orum (ass)istant
Evoplure
Posts: 43
Joined: Fri 8. Jul 2005, 02:59

Post by Evoplure »

I have a similar problem with the {ARTICLE_TITLE} replacement tag:

http://www.phpwcms.de/forum/viewtopic.php?t=8659

I don't know why your solution has not been included in the last version of PHPWCMS, it seems to be very logical...
* Maybe I'm wrong * Maybe not *
Locked