close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple language menu in template

Thread began 9/08/2011 4:27 am by CraigR | Last modified 9/08/2011 12:14 pm by CraigR | 2140 views | 6 replies |

CraigRBeta Tester

Multiple language menu in template

I am creating a multiple language site, and as such, am using a session variable to select which menu to load.

The block I added to my template is as follows…

<div id="topNavigation">
<?php switch ($_SESSION['language']) {
case 'english': //use the english menu
require_once("../CSSMenuWriter/cssmw/menu.php");
break;
case 'spanish': //use the spanish menu
require_once("../CSSMenuWriter/cssmw/spanish/menu.php");
break;
case 'mandarin': //use the mandarin menu
require_once("../CSSMenuWriter/cssmw/mandarin/menu.php");
break;
case 'hindi': //use the hindi menu
require_once("../CSSMenuWriter/cssmw/hindi/menu.php");
break;
default: //use the english menu
require_once("../CSSMenuWriter/cssmw/menu.php");
}
?>
</div>



Any pages based on this template which occur in a subfolder, work perfectly, the code above is inserted exactly as above onto my page.

However, pages in the root folder, based on the same template do not work properly, the menu block appears as follows, with the first require line (only) missing the leading ../

I would expect all of the require lines to point to CSSMenuWriter...

<div id="topNavigation">
<?php switch ($_SESSION['language']) {
case 'english': //use the english menu
require_once("CSSMenuWriter/cssmw/menu.php");
break;
case 'spanish': //use the spanish menu
require_once("../CSSMenuWriter/cssmw/spanish/menu.php");
break;
case 'mandarin': //use the mandarin menu
require_once("../CSSMenuWriter/cssmw/mandarin/menu.php");
break;
case 'hindi': //use the hindi menu
require_once("../CSSMenuWriter/cssmw/hindi/menu.php");
break;
default: //use the english menu
require_once("../CSSMenuWriter/cssmw/menu.php");
}
?>
</div>



I could create another template specifically for files in the root folder, but this seems daft. Is there something else i can do ?

Sign in to reply to this post

Jason ByrnesWebAssist

why not use Framework Builder. Add the menus as a dynamic plugin, framework builder will automatically adjust the require paths for you.

Sign in to reply to this post

CraigRBeta Tester

I think I am too far down the line with this project.

If the multi-lingual aspect was part of the original plan, I may have gone down this route

Sign in to reply to this post

Jason ByrnesWebAssist

looks like this is an issue when you have multiple require_once() statements in the same PHP block. The work around is to create a unique php block for each require_once:

php:
<?php switch ($_SESSION['language']) {

  case 
'english'//use the english menu
  
?>
  <?php
  
require_once("../CSSMenuWriter/cssmw/menu.php");
    
?>
  <?php
  
break;      
  case 
'spanish'//use the spanish menu
  
?>
  <?php
  
require_once("../CSSMenuWriter/cssmw/spanish/menu.php");
    
?>
  <?php
  
break;
  case 
'mandarin'//use the mandarin menu
  
?>
  <?php
  
require_once("../CSSMenuWriter/cssmw/mandarin/menu.php");
    
?>
  <?php
  
break;
  case 
'hindi'//use the hindi menu
  
?>
  <?php
  
require_once("../CSSMenuWriter/cssmw/hindi/menu.php");
    
?>
  <?php
  
break;
  default: 
//use the english menu
  
?>
  <?php
  
require_once("../CSSMenuWriter/cssmw/menu.php");
    
?>
  <?php
  
}
  
?>
Sign in to reply to this post

CraigRBeta Tester

thanks Jason, I'll try that.

This would be a real p.i.a. if it was a big code block

Is this a bug in dreamweaver ?

Sign in to reply to this post

Jason ByrnesWebAssist

it appears to be.

as a test i created a template with multiple require once lines to the same file:

php:
<?php

require_once("../phpinfo.php");
require_once(
"../phpinfo.php");
require_once(
"../phpinfo.php");
?>
<?php
require_once("../phpinfo.php");
require_once(
"../phpinfo.php");
?>
<?php
require_once("../phpinfo.php");
?>
<?php
require_once("../phpinfo.php");
?>
<?php
require_once("../phpinfo.php");
?>




when i applied this to a page, the results was:

php:
<?php

require_once("phpinfo.php");
require_once(
"../phpinfo.php");
require_once(
"../phpinfo.php");
?>
<?php
require_once("phpinfo.php");
require_once(
"../phpinfo.php");
?>
<?php
require_once("phpinfo.php");
?>
<?php
require_once("phpinfo.php");
?>
<?php
require_once("phpinfo.php");
?>




It seams Dreamweaver will only alter the path of the first require_once() statement in an individual php code block.

Sign in to reply to this post

CraigRBeta Tester

thanks for testing that out Jason.

I just did the same and got the same result.

putting the code into separate blocks is a good workaround, so i have done it for the 2 menus and the footer, which appears to work fine.

the workaround is (obviously) only needed for the template, when using my php switch block within a page, it works asis.

Thanks again for your help

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...