Page 2 of 2

Posted: Mon 5. Nov 2007, 10:49
by update
Thank you for staying :)
I will give it a try!

Posted: Mon 5. Nov 2007, 11:52
by update

Code: Select all

<?php
/*
   just a sample how to inject body ID - i.e. to allow specific CSS based things (or JavaScript stuff too)....
   if you define $content['body_id'] = FALSE body tag injection will be hopped

   sample will set body tag injection based on "main structure"
   if it is in home it will fall back to
 */
if(isset($LEVEL_ID[1])) { // lets say it is the main structure root
	$content['body_id'] = $LEVEL_ID[1];
		{
			if(isset($LEVEL_ID[3])) { // lets say it is the third structure level
			$content['body_id'] = $LEVEL_ID[3];
			}
		}
} else { // do nothing 
	$content['body_id'] = false;
}
?>
This is what I've got so far - now the first two levels are working as per default, from the third on it triggers anew...
Now wondering how to get this going for certain branches ov the structure tree...

Posted: Mon 5. Nov 2007, 14:01
by update
now I'm beginning to see it: defining a class (myclass_) in custom.settings.php will give me a custom class with level myclass_id if I choose this template for a certain structure item (and this one only) - aha! besides the id if wanted. Cool, really cool. I understand... will dig deeper... cool... thanks...

Posted: Wed 14. Nov 2007, 21:41
by swisscheese
Did a bit of researches and finaly would propose a little change of code. For sure OG will kill me or implement this in a future release :wink: (I hope the latter... 8) ).

EDIT: Don't do it, there is a solution without fiddling in the core code. see post below
So here's how to go:
in /include/inc_front/content.func.inc.php replace line 127-145 with:

Code: Select all

//define the current article category ID
$content["cat_id"]	= $aktion[0];

//try to find current tree depth
$LEVEL_ID  		= array();
$LEVEL_KEY 		= array();
$LEVEL_STRUCT	= array();
$level_ID_array	= get_breadcrumb($content["cat_id"], $content['struct']);
$level_count	= 0;
foreach($level_ID_array as $key => $value) {
	$LEVEL_ID[$level_count]		= $key;
	$LEVEL_KEY[$key] 			= $level_count;
	$LEVEL_STRUCT[$level_count]	= $content['struct'][$key]['acat_name'];
	if($PERMIT_ACCESS && $content['struct'][$key]['acat_regonly']) {
		$PERMIT_ACCESS			= false; // only users have been logged in get access
	} 
	$level_count++;
}
$content['body_id'] = $LEVEL_ID;
in /index.php replace line 145-157 with this:

Code: Select all

// inject body tag in case of class or id attribute
$body_inject = '<body';
if($content['body_id'] !== false) {
	if(!empty($template_default['body']['class'])) {
		$body_inject .= ' class="';
		foreach($content['body_id'] as $val) $body_inject.=$template_default['body']['class'].$val.' ';
		$body_inject .='"';
	}
	if(!empty($template_default['body']['id'])) {
		$body_inject .= ' id="'.$template_default['body']['id'].array_pop($content['body_id']).'"'; #gm# 
	}
}
$content['page_start'] .= $body_inject.'>'.LF;

if you give some values in the conf.template_default.inc.php like this:

Code: Select all

$template_default['body']['id'] = 'myid_';
$template_default['body']['class'] = 'myclass';
you get something like this for a level with id 11 whithin a level with id 3:

Code: Select all

<body class="myclass_0 myclass_3 myclass_11 " id="myid_11">
Now, you could set in your css attributes for body.myclass_3 and all sublevels of this are affected.

You can try it here: http://www.zeltnerweg9.ch/index.php
Have fun
swisscheese

Posted: Thu 15. Nov 2007, 00:20
by Oliver Georgi
No good solution! Sorry to say so. There is NO need to hack the core code to get that. Use frontend_render to set the var!

Oliver

Posted: Thu 15. Nov 2007, 09:03
by swisscheese
Thanks Oliver. I made a frontend_render script:

Code: Select all

if(count($LEVEL_ID)) { 
	foreach($LEVEL_ID as $val) $bodyclass .= $template_default['body']['class'].$val.' ';
	$content['all'] = '<div class="'.$bodyclass.'">'."\n".$content['all']."\n</div>\n";
}
Altough: this will ad another div around the whole content. I don't have access to $content['page_start'] in frontend_render, do I? If I had, I could preg_replace the body tag...

have fun
swisscheese

Posted: Thu 15. Nov 2007, 10:49
by Oliver Georgi
all you have to do - inject these vars

Code: Select all

$template_default['body']['id'] = '';
$template_default['body']['class'] = '';
and maybe set

Code: Select all

$content['body_id'] = '';
in your frontend render script.

Oliver