www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > HTML

    HTML Discussion and technical support for building, using and deploying HTML sites.

    Reply
     
    Thread Tools Rate Thread Display Modes
      #1  
    Old 03-20-2010, 10:35 PM
    LeviClaassen LeviClaassen is offline
    Registered User
     
    Join Date: Mar 2010
    Posts: 10
    Like to same filename in different directory

    Did 15 mins of Google searching, nothing useful. As the thread location suggests, I am working in HTML. No switching for me at this point in time.

    So here's what I want. I have a Dutch section (/nl/) and an English section (/en/)of my website. In my navigation bar I have 2 flags representing each language. Is it possible to link the user to the same file but in a different directory if they click one of the flags? So if they are on /nl/about.html, and they click on the English flag, they are linked to /en/about.html.

    By the way I am using dwt's (Dreamweaver Templates), so that's why I would want one piece of code and be done with it.


    Thanks in advance!
    Reply With Quote
      #2  
    Old 03-20-2010, 11:24 PM
    Kodias Kodias is offline
    Registered User
     
    Join Date: Mar 2010
    Posts: 2
    Not really sure what the problem here is, it wouldn't be linking to the 'same' file if its in a different directory, you'd have to make two copies of the file and place one in /nl/ and one in /en/.
    Reply With Quote
      #3  
    Old 03-21-2010, 12:09 AM
    tirna's Avatar
    tirna tirna is offline
    Registered User
     
    Join Date: Mar 2010
    Location: Melbourne, Australia
    Posts: 2,030
    I found this useful script on the www which returns the basename of your web page's current url.

    If you set the suffix argument to an empty string you get the full base name including filename extension.

    If you set a suffix like '.htm', you get the basename minus the suffix, assuming your url ends in .htm

    You then only need to append it to the directory path to the alternate language folder on your site and then redirect your browser using JS to the new url.

    I'm not a Dreamweaver user so I don't know how to integrate this script into your code. Maybe someone else can help or offer a better solution.


    Code:
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title></title>
    <script type="text/javascript">
    function basename(path, suffix) {
        // Returns the filename component of the path  
        // 
        // version: 910.820
        // discuss at: http://phpjs.org/functions/basename    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
        // +   improved by: Ash Searle (http://hexmen.com/blog/)
        // +   improved by: Lincoln Ramsay
        // +   improved by: djmix
        // *     example 1: basename('/www/site/home.htm', '.htm');    // *     returns 1: 'home'
        // *     example 2: basename('ecra.php?p=1');
        // *     returns 2: 'ecra.php?p=1'
        var b = path.replace(/^.*[\/\\]/g, '');
            if (typeof(suffix) == 'string' && b.substr(b.length-suffix.length) == suffix) {
            b = b.substr(0, b.length-suffix.length);
        }
        
        //return b;
        
        alert(b);
    }
    </script>
    </head>
    
    <body onload="basename(window.location.href,'');">
     
    <h1>hello world</h1>
     
    </body>
    </html>

    Last edited by tirna; 03-21-2010 at 12:14 AM.
    Reply With Quote
      #4  
    Old 03-21-2010, 02:13 AM
    Fang's Avatar
    Fang Fang is offline
    Resistance is futile
     
    Join Date: Apr 2003
    Location: Netherlands
    Posts: 20,058
    __________________
    At least 98% of internet users' DNA is identical to that of chimpanzees
    Reply With Quote
      #5  
    Old 03-21-2010, 06:46 AM
    LeviClaassen LeviClaassen is offline
    Registered User
     
    Join Date: Mar 2010
    Posts: 10
    Quote:
    Originally Posted by Kodias View Post
    Not really sure what the problem here is, it wouldn't be linking to the 'same' file if its in a different directory, you'd have to make two copies of the file and place one in /nl/ and one in /en/.
    I should have been more clear. I want it to link to a file with the same NAME as the current file, but in a different directory.
    Reply With Quote
      #6  
    Old 03-21-2010, 07:09 AM
    LeviClaassen LeviClaassen is offline
    Registered User
     
    Join Date: Mar 2010
    Posts: 10
    Quote:
    Originally Posted by tirna View Post
    I found this useful script on the www which returns the basename of your web page's current url.

    If you set the suffix argument to an empty string you get the full base name including filename extension.

    If you set a suffix like '.htm', you get the basename minus the suffix, assuming your url ends in .htm

    You then only need to append it to the directory path to the alternate language folder on your site and then redirect your browser using JS to the new url.

    I'm not a Dreamweaver user so I don't know how to integrate this script into your code. Maybe someone else can help or offer a better solution.


    Thanks a lot for the effort, it's a pity that my Javascript skills suck. I think I know for about 1/4 what that all means. Maybe less even...

    If someone would like to help me out it would be awesome, but I guess I'm not really asking for it, since a solution has been given, and if I start learning Javascript now, I could do it. The thing is, I would love to learn Javascript, but I would also love to have my website up and running in about a week.

    So if anyone wants to help me with this it would be freakin great.
    Reply With Quote
      #7  
    Old 03-21-2010, 11:39 AM
    LeviClaassen LeviClaassen is offline
    Registered User
     
    Join Date: Mar 2010
    Posts: 10
    Oops as I was going through my tabs I noticed I spelled "Like" instead of "Link" I don't think I have the privilege to change this, can someone do this please? That way other people can find it too
    Reply With Quote
    Reply

    Bookmarks

    Tags
    alternative, directory, filename, html, link


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:11 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.