[still lost] Changing header logo based on menu-parent
Posted: Tue Aug 07, 2007 7:58 am
Berlin 070807
Dear Mark,
Thanks for your suggestions. I am also somewhat new and very much learning by doing i.e. change on thing and see what happens. It has really been very good fun and rewarding. I am still having problems, either I get two of the same images or nothing at all. The "Start Photo Change Second" works a treat albeit "Start Photo Change First" copying it. Okay, here is my code from the three files. I have tried:
(a) duplicating UDF and calling it "get_root_page_alias2" and then changing ref to it in Template. Then duplicating CSS with different image - no success
(b) changing div id (as below)
(c) changing UDT "$thisPage = $gCms->variables['content_id'];" to "content_id_a", and then changing CSS to e.g. div#support_a{
So I guess, really am very new to this, (i) UDT gets page name (ii) cross references with CSS, which (iii) produces photo. If this is right, I need to make sure that there is a change to the page name somehow. The only way would be to append a suffix to the page name in the duplicate "get_root_page_alias2" which can be also placed in the same CSS. i.e. (a) + (c) above. Does this make any sense or have I lost it completely? If so, how does one do that
I am really very happy for any further suggestions that you can make. Very sincerely looking forward to hearing from you,
JT
1. CODE IN TEMPLATE
{* Start Sidebar *}
{* Start Photo Change first *}
{get_root_page_alias assign="photoupper1"}
{* End Photo Change *}
{* Start Sub Navigation *}
Sub Navigation
{* NB! The below is only added because several default templates use the same menu stylesheet, to "force" the subnavigation to act as if it's the second level in a list *}
{menu template='simple_navigation.tpl' start_level='2' collapse='1'}
{* End Sub Navigation *}
{* End Content *}
{* Start SideBar Horizontal Crosssite Navigation *}
{menu template='simple_navigation.tpl' start_page='crosssite'}
{* End SideBar Horizontal Crosssite Navigation *}
{* Start Photo Change second *}
{get_root_page_alias assign="mainpage"}
{* End Photo Change *}
{* End Sidebar *}
2. CODE IN CSS
div#support{
/* you can set your own image here */
background: url(images/cms/support.gif) no-repeat right 0;
margin-right: 0%; /* set image similar position */
height: 279px; /* adjust according your image size */
}
3. UDT CODE
global $gCms;
global $smarty;
$manager =& $gCms->GetHierarchyManager();
$var = 'root_page_alias';
if( isset($params['assign']) && $params['assign'] != '' )
{
$var = $params['assign'];
}
$result = "NO RESULT";
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
$currentContent =& $currentNode->getContent();
$result = $currentContent->Alias();
$currentNode =& $currentNode->getParentNode();
}
$smarty->assign($var,$result);
Dear Mark,
Thanks for your suggestions. I am also somewhat new and very much learning by doing i.e. change on thing and see what happens. It has really been very good fun and rewarding. I am still having problems, either I get two of the same images or nothing at all. The "Start Photo Change Second" works a treat albeit "Start Photo Change First" copying it. Okay, here is my code from the three files. I have tried:
(a) duplicating UDF and calling it "get_root_page_alias2" and then changing ref to it in Template. Then duplicating CSS with different image - no success
(b) changing div id (as below)
(c) changing UDT "$thisPage = $gCms->variables['content_id'];" to "content_id_a", and then changing CSS to e.g. div#support_a{
So I guess, really am very new to this, (i) UDT gets page name (ii) cross references with CSS, which (iii) produces photo. If this is right, I need to make sure that there is a change to the page name somehow. The only way would be to append a suffix to the page name in the duplicate "get_root_page_alias2" which can be also placed in the same CSS. i.e. (a) + (c) above. Does this make any sense or have I lost it completely? If so, how does one do that
I am really very happy for any further suggestions that you can make. Very sincerely looking forward to hearing from you,
JT
1. CODE IN TEMPLATE
{* Start Sidebar *}
{* Start Photo Change first *}
{get_root_page_alias assign="photoupper1"}
{* End Photo Change *}
{* Start Sub Navigation *}
Sub Navigation
{* NB! The below is only added because several default templates use the same menu stylesheet, to "force" the subnavigation to act as if it's the second level in a list *}
{menu template='simple_navigation.tpl' start_level='2' collapse='1'}
{* End Sub Navigation *}
{* End Content *}
{* Start SideBar Horizontal Crosssite Navigation *}
{menu template='simple_navigation.tpl' start_page='crosssite'}
{* End SideBar Horizontal Crosssite Navigation *}
{* Start Photo Change second *}
{get_root_page_alias assign="mainpage"}
{* End Photo Change *}
{* End Sidebar *}
2. CODE IN CSS
div#support{
/* you can set your own image here */
background: url(images/cms/support.gif) no-repeat right 0;
margin-right: 0%; /* set image similar position */
height: 279px; /* adjust according your image size */
}
3. UDT CODE
global $gCms;
global $smarty;
$manager =& $gCms->GetHierarchyManager();
$var = 'root_page_alias';
if( isset($params['assign']) && $params['assign'] != '' )
{
$var = $params['assign'];
}
$result = "NO RESULT";
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
$currentContent =& $currentNode->getContent();
$result = $currentContent->Alias();
$currentNode =& $currentNode->getParentNode();
}
$smarty->assign($var,$result);