Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How do I configure "smart" language-switch buttons in an included HTML header?

Participant ,
May 16, 2021 May 16, 2021

Nutshell: Does a button in an included header know what page it is on?

 

Background: I am in the process of completely re-coding some bilingual websites that were generated using Netobjects Fusion. Each site has a homepage and complete web structure in English and a parallel structure in Spanish. So I have a page: aboutus.html and aboutus-es.html & so on. The Spanish page (home-es) is below the English home page (index.html. Every page has 2 language switch buttons in the header: English and Spanish actually as flags. The buttons take you to the respective home page - Not best for the user but it was easier for me :).  (Using Google-Spanish or equivalent is not an acceptable solution for us.) The sites need to be completely rebuilt but I am satisfied with the basic structure and plan to retain that for the time being. All of this was easy in Fusion and I am trying to save myself a lot of work and pain by having included headers, footers, menus etc. in the pages that I will code in HTML. While open to other suggestions, my reading so far indicates that using server-side includes with w3-include-html attribute or PHP would be the most practical solution, assuming my host allows it (am asking).  

 

Questions: I want the language buttons, which are in the included headers, to take the user to the equivalent page in the other language rather than always to the home page. I am hoping that I can use some simple JS to have the button go look on the page it finds itself in for the correct link. That means the buttons will have to "know" what page they are on. Is all of this feasible? Does it depend on how I include the headers? Is there a better way to include the headers with this functionality in mind?

5.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2021 May 19, 2021

Essential cookies are not the same as optional ones. 

 

Regardless of what users say or do, Facebook, Google, Bing et al track data and share it on some level.  If you think they don't, you're kidding yourself.

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2021 May 19, 2021

To illustrate what I said above, I just recived this email (indicative of similar emails that land in my junk box)

BenPleysier_0-1621432782778.png

Tracking, another word for stalking.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 19, 2021 May 19, 2021
quote

seriously, if people still disable JavaScript, I wonder what they can really see on the web ????
moreover some time ago I struggled like crazy to disable Javascript on Firefox ...


By @B i r n o u

 

Playing the old card about javascript being disabled. Tell that to those who use React, Angular, Vue and the rest which soley rely on javacript to constuct a whole website........that arguement isnt going anywhere but in the dustbin.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 18, 2021 May 18, 2021

Is this site just all manual and no CMS / Headless CMS driven at all?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 18, 2021 May 18, 2021

three that everyone has a song and dance... and the OP still hasn't intervened in the debate...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 19, 2021 May 19, 2021
quote

three that everyone has a song and dance... and the OP still hasn't intervened in the debate...


By @B i r n o u

 

Hi everyone - I would love to intervene in some constructive way but, as I mentioned before, I lost my computer and an awaiting a replacement which I am hoping arrives today, via Amazon and a visiting friend from the USA. So I have not been able to try any of the suggestions yet. But the following may help:

 

Spanish headers only go on Spanish pages: English on English. So I anticipated that the JS in the included header to activate a link on the "host" page should be very simple (maybe 1 line?). Similarly the JS on the "host" page would be just as simple, calling the equivalent page in the other language. I would try it if I could but that will have to wait.

 

Thinking further: I will probably dispense with one of the buttons. So if you are on the English page you see the Spanish flag button and vice-versa. 

 

Of course, I still have to choose a mechanism to do the actual inclusion. I was thinking PHP, in which case all my pages would have to be .php's - Is there any downside to this? How about the w3-include-html attribute?

 

Regarding the cookie debate: maybe when the user clicks to change language a popup simply asks:

"Would you like us to save this choice for future visits (using a cookie)?"

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2021 May 19, 2021

well, nice to see you back...

refer to the very first comments of this thread, OSGood and I gave you some JS script that could handle what you're expecting...

just let us know

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2021 May 19, 2021
quote

How about the w3-include-html attribute?

========

Why would anybody use that???!!!  That's an ugly, complicated mess. 

There is no downside to using PHP files if your server supports PHP code. 

PHP include statements are simple and straightforward with one line of code.

 

<?php require_once('Includes/header.html'); ?>

 

quote

Would you like us to save this choice for future visits (using a cookie)?

========

Either the end user's browser accepts cookies or it doesn't.  By default, all browsers accept cookies unless settings are intentionally changed by the end user, corp / gov't IT dept or security software.  In those cases, asking will make no difference because the cookie cannot be saved. 

 

If you suspect a big chunk of your target audience have cookies disabled, use server-side PHP sessions instead.  Sessions are more reliable.

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 19, 2021 May 19, 2021
quote
 

How about the w3-include-html attribute?

========

Why would anybody use that???!!!  That's an ugly, complicated mess. 

There is no downside to using PHP files if your server supports PHP code. (my emphasis)

 

By @Nancy OShea

"If" is the key - I'm still waiting for an answer from my host re: PHP. Looking at alternatives in case. Can always change service but may be an easier solution if another method was viable .

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2021 May 19, 2021

For Linux hosting, use PHP code.

For Win IIs hosting, use ASP.net code and Visual Studio Code editor which is made by Microsoft.

 

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 25, 2021 May 25, 2021
quote

For Linux hosting, use PHP code.

For Win IIs hosting, use ASP.net code and Visual Studio Code editor which is made by Microsoft.

 

By @Nancy OShea

 

Hi Nancy. I am finally back in operation and ready to start tackling this issue again. I don't see myself using PHP for anything more than including headers, menus etc. with "include...". All I want to do is test pages locally before uploading to my host server. But to do even this much I understand I need to setup a server on my PC. When I look to activate the IIS feature in Win10, there are a bunch of options - Which of these do I need?

 

Galeodan_0-1622000349011.png

Then I also need to install ASP.net. and then PHP - Any more? I have searched quite extensively but it gets too technical too quickly. What I really need is a guide for total dummies on how to install the very basics and then run them. I am mostly using VSCode these days.

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 25, 2021 May 25, 2021

None of the above. Install Wamp and you have your server. Then use the `www` folder for your sites.

BenPleysier_0-1622005286625.png

 

 

 

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 26, 2021 May 26, 2021
LATEST

What Ben said.  Install WAMP server.  

 

In DW, define your local testing server by going to Site > Manage Sites.  See screenshots below.

 

Local Site FolderLocal Site Folder

 

Add testing serverAdd testing server

 

Path to localhostPath to localhost

 

Server modelServer model

 

Final screenFinal screen

 

 

I also highly recommend that you disable Real-Time Preview in Preferences.  Switch to Default to Static Browser Preview.

 

Preferences > Real-Time PreviewPreferences > Real-Time Preview

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2021 May 19, 2021
quote I was thinking PHP, in which case all my pages would have to be .php's - Is there any downside to this? How about the w3-include-html attribute?
By @Galeodan

 

yes, you will have to change all the html files to php, for that purpose, first make a save back up of the main folder, then you have many choices for handling the batch process...

 

as you're under windows, you can run

https://www.thewindowsclub.com/batch-rename-files-extensions-windows

 

or as you're a Creative Cloud member, you can run Bridge

https://wikis.utexas.edu/display/comm/Adobe+Bridge+-+Batch+Convert+file+names+or+extensions

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 19, 2021 May 19, 2021
quote

yes, you will have to change all the html files to php, for that purpose, first make a save back up of the main folder, then you have many choices for handling the batch process...

 

By @B i r n o u

No problem - There are no pages yet - Starting from scratch anyway 🙂

I won't be salvaging anything from the old pages - Just the texts...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines