Also, should we seriously consider using this or a similar implementation for MODx multiple language sites by default in the manager? I would like to have this addressed much sooner than later. (Jason, see any problems in porting madmages’s solution to the contexts/versions in Tattoo?)
Or, simply create a page and provide as many different versions of the content (and each one of it’s elements, e.g. snippets, templates, chunks, TV’s) you want in the page, and then have system/context/user preferences determine the best matching cultural revision for each request to the page.
A small demo you can find in http://www.mindreamz.net/modx091/ but I would like the MODx-gurus to look at my code to know if I used the right functions in the right places (going into the core code to find out which function to use is not a great thing, maybe sometimes I used a deprecated function or something like this)
The goal was to provide a multi-language-content site, in which the user can choose a preferred language and browse the site reading pages in that language if they are available, and been redirected to a "default language page" if not.
My solution is the following:
1) there is a $_SESSION variable that stores the preferred language choice of the user;
2) I modified the *_site_content table adding two fields:
- contentLang, that stores something like "en", "it", "fr", ...
- refId, the id of the page in the default language which this one is a translation
3) I added a snippet to show the language flags for the user choice
4) I added a plug-in that redirects to the right-language page
5) I modified the DropMenu to show only the chosen language entries
6) I modified the manager in these ways:
- in the document tree, each page has next to it its current translations (you can click on them and go to the translation, without the need to have a different tree for each language and to have not every page translated)
- while vieweing a document, you can also see in which language is the content and you have a button that duplicates the page to begin to translate it
- in the settings page you have to write which languages your site is in and the default language
The only thing that is to be implemented is a plug-in that rebuilds the tree accordingly after the insertion of a new translation (it is needed and you can easily figure out why)
Now, then, how can I show my solution? I can give to someone the access to my manager, in order to see my modifies. Or... what else?
Sounds like a reasonable plan.
Would this option work for a multilingual site:
- create textbox/WYSIWYG TV’s for each language (english, spanish, french, etc.)
- have snippet that reads from either session,cookie, or advanced_user_table** which TV to load
- if nothing is set go to default
Would this work for multilingual sites?
Using TVs would be your best bet for now. As for future directions, all the metadata of a document will also be able to have multiple translations and change revisions, just as the content will, with the exception of alias, which is used to create a unique resource identifier/locator (URI/URL) for the page.
*problem: Another thing, translation does includes longtitle, summary and etc, which each snippets developer will need to be able to detect that.
- would you be able to declare these with the TV’s?
Yes being worked on already for 1.0.
I’m a newbie but an idea guy too. What do you guys think, or are you already working on these things for 1.0?
Why not use web_user_settings table to store this information? Just need to use unique names for your properties and you should be fine to use this existing table for this purpose. It’s kind of what it is meant for.
PS - advanced_user_table** = My plan is to create an addon where a user can describe many attributes for their user account. This would be a new table with the id’s linked to the normal user table. If this happens, the user could also describe their preferred language (or template, etc.)
Indeed; table-size is just as important a consideration as overnormalization can be, where you have unnecessary joins to frequently used data. It’s a balancing act, but I really feel the benefits of isolating content from the definition of a page are important.
PPS - Jason, I agree more items need to be removed from site_content table instead of more items being added to it.
Quote from: ProWebscape at Jun 27, 2006, 04:23 AMWhy not use web_user_settings table to store this information? Just need to use unique names for your properties and you should be fine to use this existing table for this purpose. It’s kind of what it is meant for.
PS - advanced_user_table** = My plan is to create an addon where a user can describe many attributes for their user account. This would be a new table with the id’s linked to the normal user table. If this happens, the user could also describe their preferred language (or template, etc.)
You shouldn’t need to add columns to this table, only rows of key/value pairs per user, which it already handles.
1. How do you plan to account for this table (with its added columns) during MODx upgrades? [or is it expected for the MOD user to manually go through the SQL updates?]
Just name them uniquely and all should be well with the world. For instance, prowebscape.default_template could be a setting_name, with a setting_value of 2 for webuser 1. I don’t think we’d ever maliciously try to overwrite that value on upgrades, and if we did, whew, would we deserve a proper ass kicking or what
2. Is there any db schema/API/rules to prevent other addons from clashing with additions to this table? Aka, best practices?

Flattery will get you everywhere here.
PS - You guys have done one HELLUVA a job on this. I was working with J! today and just couldn’t bear it.

<?php // // [Plugin] LanguageVar // if(isset($_GET['lang']) && trim($_GET['lang']) != '') $_SESSION['lang'] = strtolower($_GET['lang']); ?>
<?php // // [Snippet] LanguageVar // // Usage: [!LanguageVar? &var=`content`!] // $default_lang = 'en'; if(!isset($var) || trim($var) == '') $var = 'content'; $lang = ''; if(isset($lang) && trim($lang) != '') $lang = '_'.$lang; else if(isset($_GET['lang']) && trim($_GET['lang']) != '') $lang = '_'.strtolower($_GET['lang']); else if(isset($_SESSION['lang']) && trim($_SESSION['lang']) != '') $lang = '_'.strtolower($_SESSION['lang']); if($lang == '_'.$default_lang || !isset($modx->documentObject[$var.$lang]) || trim($modx->documentObject[$var.$lang][1]) == '') $lang = ''; if(isset($edit) && $edit = true) return '[*#'.$var.$lang.'*]'; else return '[*'.$var.$lang.'*]'; ?>
This is my short term solution that I use for my current website. It uses TV and session