CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Menu : how to assign a default value

Print topic Send  topic

Author Message
DvdW

Posts: 10
Posted: 04/12/2012, 2:55 AM

Hi,

I've build an application with a menu (static). My question is : "How can I assign a default selected value" ?

The default page for my website is index.php so if I try http://www.mywebsite.com, I receive the index.php page but the menu doesn't highlight the Home item...

If I navigate and select the Home item (wich refer to index.php), it works well.

So :
http://www.mywebsite.com doesn't highlight the Home item
http://www.mywebsite.com/index.php highlight the Home item

Any idea ?
Dominique
View profile  Send private message
DataDoIT
Posted: 04/20/2012, 9:04 AM

Dominique, the menu is smart enough to know the 'exact' page you're
looking at, but in your situation the web server is feeding the default
page without the need to display the actual page or file name.

To deal with that, or any other submenu items, you can control it via
custom coding. For your menu's Before Show Row, add this custom code event:

global $CCSLocales, $FileName, $Tpl;

//An index page.
if ($FileName == "index.php") {
if ($Container->Menu1->ItemLink->GetValue() ==
$CCSLocales->GetText("Home", CCGetSession("locale","")) ) {
$Tpl->SetVar("Menu1:Submenu", "active");
}
}


Now we're using translations, so that's why you see the $CCSLocales
stuff there, but you can omit that.

Also adjust references to the name of your menu component accordingly.

You can see this concept in action at
http://www.codechargesupport.com/accounts/login.php

Notice the 'My Account' top menu item is highlighted, even though the
actual link for that menu item is to index.php.
DvdW

Posts: 10
Posted: 04/25/2012, 12:18 AM

Tanks a lot for your help.


I've try your solution and I have one problem but it finaly works...

I've try in the Header_MainMenu_BeforeShowRow function:


global $FileName, $Tpl;

if ($FileName == "destinations_list.php") {
if ($Header->MainMenu->ItemLink->GetValue() == "Destinations") {
$Tpl->SetVar("MainMenu:Submenu", "active");
}
else $Tpl->SetVar("MainMenu:Submenu", "");
}

But nothing happened in the result page (but the call is well reached, I've put a trace and it's ok)...

After that, I've add a locale variable (MainMenu:MSubmenu) in the menu section in html page:

<!-- BEGIN Item -->
<!-- BEGIN OpenLevel --><ul><!-- END OpenLevel -->
<li><a href="{ItemLink_Src}" class="{MainMenu:Submenu}{MainMenu:MSubmenu}" target="{MainMenu:Target}" title="{MainMenu:Title}">{ItemLink}</a>
<!-- BEGIN CloseItem --></li><!-- END CloseItem -->
<!-- BEGIN CloseLevel --></ul></li><!-- END CloseLevel -->
<!-- END Item -->

And it works with the following code :


global $FileName, $Tpl;

if ($FileName == "destinations_list.php") {
if ($Header->MainMenu->ItemLink->GetValue() == "Destinations") $Tpl->SetVar("MainMenu:MSubmenu", "active");
else $Tpl->SetVar("MainMenu:MSubmenu", "");
}

So it doesn't work with MainMenu:Submenu but it works with MainMenu:MSubmenu...

I don't know why :-)
Dominique
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.