Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Main Menu (more than one language?)
#1
Let me try to phrase this correctly.

Is it possible to change the main menu to different language to the main page?
If someone clicks on (say) a small flag. The page is easy to change. But is it possible to change the main menu to a second language on another page? So say the main pages are in English and then there are pages translated into French with the main menu to match.
Just in case it is not possible and I am waiting time trying.

Thanks, in advance for any help.
Reply
#2
With the current way the menu is generated this is not possible. Multilingual websites are still a bit above GetSimple’s capabilities. I thought about working on this, but to actually get it right will take a lot of time.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#3
Thank you for the reply.

I am no PHPer. But, I have no choice and I will take a look, since there is no "easy way".

Thanks once again.
Reply
#4
you could use my customfields plugin to add extra fields for other languages...
take the original menu function and change to use your new fields, still using the sort order from the
original menu.
My Github Repos: Github
Website: DigiMute
Reply
#5
@Mike: And another customfield so you can tell the theme what language menu to show… I think it really is not that easy in the end.

This might make for a challenging plugin idea.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#6
Realistically you could probably take the generic code for the navigation, add into a plugin and add new code? i don't see it would be overly difficult? i would think anyway.

Then it's simply call a function in your template.

Allow the selection of a menu based on the currently language selected, and go from there. would it be overly difficult? my only question is if it would support all required characters correctly.
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#7
crashfellow Wrote:Realistically you could probably take the generic code for the navigation, add into a plugin and add new code?
That’s the gist of it on the backend, it’s the way you save all the data that is problematic. As the webmaster you’ll have to fill in a field on all pages so it knows what language that page is. It will also need a way to know what Dutch (as an example) page goes together with what English page…

This will either be a lot of different fields for the webmaster to fill in (not really in the spirit of GetSimple) or we’ll have to come up with some other smart data model.

crashfellow Wrote:My only question is if it would support all required characters correctly.
It will, you just need to save everything through the addCData() method of the extended SimpleXML class found in GetSimple.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#8
But if this is just for the menu... does this text get loaded from the en language file??

If not it should be :| essentially all text should be, to create full multi-language ability yeah?

Like my currently gripe is the inability to add to this file through plugins. as it would be super useful!
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#9
The website menu is not a file, neither does it use any language files. The way the menu is built is by checking each and every single page XML file. From those it gets your per-page configured menu title, page title, whether it should be in the menu or not and what priority is set. It then sorts this all and prints a menu.

To have multiple separate menus will make for a challenge, as the way it is generated right now would be completely useless.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#10
Ahhh true true... i feel you now...

What if the language file was dynamic? in that you could add and remove as required? so when you create a new page, the page title is added to the file, then removed when the page is deleted, or adjusted when edited?

Then if you use multiple languages or an alternate language, it would add it to that language file instead? i guess that's just wishful thinking... but i agree, at the current form i dont see it's possible without a fairly major plugin built.
Nothing is too difficult... anything is possible.
'But you tried, and you failed.. the important thing? never try'
Reply
#11
I believe that GS needs to move it's menu function to use an external xml file that is fully customizable.
That would be the next step in fixing any menu issues as you could essentially name all links whatever you want, and also arrange then in whatever order you would like.
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#12
I actually have a plugin that moves the complete menu into an external XML file… I’m still wondering about just how to proceed now.

I originally created it for someone who was planning to be using quite a few pages and wanted to save on the file calls. As he kinda commissioned it (what do you want me to do? I love petty cash) I don’t know whether I’m going to publish is it any time soon.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#13
If you have that setup Ziggy, just think of the possibilities. You could have a fully customized solution. Have an admin area when your sort the menu items and create hierarchy at the same time.
Clients always want to be able to change the content of their pages, but they are unwilling to do so.

Have you ever coded in your underwear before?
Reply
#14
I apologize for editing you but....
Zegnåt Wrote:it’s the way you save all the data that is problematic. As the webmaster you’ll have to fill in a field on all pages so it knows what language that page is. It will also need a way to know what Dutch (as an example) page goes together with what English page…

This will either be a lot of different fields for the webmaster to fill in
So for what I want ( a small site) it can be done!

Yes I understand the debate about the need for a plugin.
But, what I am looking for can be done. Big Grin For this job I am willing to edit the pages manually.
Reply
#15
holesovice Wrote:So for what I want ( a small site) it can be done!
For sure, it can be done for bigger sites too—as long as you don’t mind having to fill in a x-amount of extra fields on page creation (and these multiplied by the number of languages you’re using).

holesovice Wrote:Yes I understand the debate about the need for a plugin.
Sorry, we got of track a little there.

If you just want this for your little site and don’t mind manually setting up something we could call “links between pages” you can start developing it right now. Throw in Mike’s CustomFields plugin for the extra settings you need. If you’re website only sports 2 languages you’ll need 2 fields. In the first field you throw an identifier (maybe just a 0 of a 1) so you can tell what language the current page is written in. In the second field you fill in the page slug of the equal page in the other language. Now you use your theme coding to link these together.

Of course it would leave the whole menu function still open. You’ll need to recode a menu function that will check the variable of the first custom field and only display pages that share the same variable. This way you’ll only display one language in the menu at a time.

Don’t know how much of this coding you think you are capable of, so don’t hesitate to ask us for help!
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#16
Zegnåt Wrote:Don’t know how much of this coding you think you are capable of, so don’t hesitate to ask us for help!

Oh I can't do any of what you said! I just need to know IF it can be done.
If it can be done. I can probably work it out. (????? yeah right)
That is the fun part.


As for the site. it is a small site. I posted it in the "Sites Using GS" forum. But I am not the owner.
I originally did the site in html css. But the owner kept screwing the site up by trying to write to the front page.
I got tired of repairing the site and dropped GS in.
GS is perfect for small sites where the owner wants some control

The only problem is that the site owner wants the pages in a second language (Czech).
The pages exist (obviously the easy part). But I have been struggling with the changing the menu.

All I need to know is if it is possible or impossible.
Thank you for the reply. Thank you for the help so far. Thank you for the offer of help.

Will let you know how it goes.
Reply
#17
Zegnåt Wrote:Of course it would leave the whole menu function still open. You’ll need to recode a menu function that will check the variable of the first custom field and only display pages that share the same variable. This way you’ll only display one language in the menu at a time.

Don’t know how much of this coding you think you are capable of, so don’t hesitate to ask us for help!
Help?

Sorry I got dragged off on something else.

Can anyone point me in the right direction?
Reply
#18
Did you get anywhere with CustomFields or the code at all? Creating a field with that plugin will allow you to specify language on a per-page basis, then you can code up the template to check this variable to know what menu to display.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#19
Zegnåt Wrote:then you can code up the template to check this variable to know what menu to display.
I understand that i got somewhere with the plugin.
It is the code up the template part that i am not getting
Reply
#20
To give you an idea what I mean:
Code:
if (returnCustomField('language')=='en') {
   englishMenu();
} else if (returnCustomField('language')=='fr') {
   frenchMenu();
} else {
   englishMenu();
}
Now if you would have a CustomField labelled “language” you could set it to en or fr. The above PHP would check this and run a different function depending on what you put in. This way, when you have made two different menu functions, you can only show certain menus on certain pages.

The key is using returnCustomField() within an if-statement to change your pages content depending on a specific field.

I hope this pointer can get you started Smile
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#21
Another possibility, if you use fancy url's and don't mind having only one level in your pages, would be using this structure:

WEBSITE/en/sample-page-in-english
WEBSITE/cz/sample-page-in-czech

('en' and 'cz' would be the slugs for each language's home page)

This could also be done without fancy url's, but wouldn't look so nice :-)

In Zegnåt's sample php code you would check for the parent page (instead of a customfield)
Reply
#22
Thank you for your help. While trying to do what you suggested. There was a small outbreak of inspiration.
I am originally trained as an engineer.
So....

An engineers solution......


Create a Component called menu2
<ul>
<li>xxx </li>
<li>xxx </li>
<li>xxx </li>
</ul>

Create a second template called template2
In the 2nd template
Replace
<div id="menu">
<ul><?php get_navigation(return_page_slug()); ?></ul>
</div>

with

<div id="menu">
<ul><?php get_component('menu2'); ?></ul>
</div>


When writing the new page with the 2nd menu, use the 2nd template.
The solution works. But it probably not "correct".
Reply
#23
Obviously it’s correct, it’s just not that flexible as you’ll have to edit the menu by hand every time.

Well, it’s a good solution, let’s just say that it’s not my solution Smile
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#24
Zegnåt Wrote:Obviously it’s correct, it’s just not that flexible as you’ll have to edit the menu by hand every time.

Well, it’s a good solution, let’s just say that it’s not my solution Smile
Your solution is better.
There seems to be a "problem" with the plugin. I must not have it set up right. The plugin does not seem to save the choices.
If it does. I do not know where.

The idea of changing templates instead of one line of code is a less than ideal solution.
But considering time constraints. It will have to do.

Thank you once again. I have to finish this off today and then move onto a project using your multi-level navigation.
Do you know that a lot of the links to the plugin are returning 404?
Reply
#25
holesovice Wrote:I have to finish this off today and then move onto a project using your multi-level navigation.
Very good choice ;-)
holesovice Wrote:Do you know that a lot of the links to the plugin are returning 404?
Yes, I know. I removed it from my server now that I’m busy building a new website. It is downloadable as attachment here on the forum, but I honestly hope to open up version 3 soon. That one is currently in closed beta, just drop me a line if you’d be interested in giving it a spin.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply




Users browsing this thread: 1 Guest(s)