Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracking pages between different language sites? 1

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
0
0
Hi All

I am working on a website that has 3 languages, probably more in the future. The menus for this site are all stored in the same table, with a flag for which language it is:

Code:
menu_id, language, menu_title

The website loads all menus "where language = x"

The admin can create pages in each language separately in the cms. They can add a language X page with content that is not necessarily available in one of the other languages but we can assume that most will be available in every language.

When the user clicks one of the language flags the site should switch to that language. Normally I would just let the flag link to the homepage but in this case I want the user to switch to the same page but in the language they selected. If that page is not available in that language it would default to the index.

My question is: how to best track which pages belong together in the database?


My current ideas are:

Have a table that collects id's of pages that are matched together by the admin when they create a new page via a pull-down for each other language where they can select the page that matches it.

Code:
match_id langx_id langy_id langz_id

I hate making tables like this though as it can get very messy :/

The other option I thought of would be to have some common identifier in the menu table:

Code:
menu_id, identifier, language, menu_title

This would store a shared secondary ID between each page that belongs together, using the same pull-down method for the admin to decide this.

are there any other better ways to track which pages belong together and to match pages in the cms? please let me know if you have any.

Thank you!
Thomas


site | blog | iphones |
 
By belong together you mean the ones with the same language?

Make a table that holds the pages. And just add a column that has a language flag.

For instance:

page_id, lang_id, page_name, page_path.

Then all you need to do is perform a query to find the desired page, if it returns a result, you use the page_path to link to that page, otherwise, you load a default English page for it if no language specific page exists.

SELECT page_path WHERE page_name LIKE '%thename%' AND lang_id=x

You should be getting a single result back.

You can also perform a language search and get all the pages from a specific language back.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
Hi Vacunita

no, i mean all pages that are the same but in different languages.

for example I will have the page "company_info.html" in english and the same page but with a different language name in another 2 languages.
when the user is on this page and he clicks the flag for the other language they would be sent to the same page but in a different language. For the user it is the same page, but for the system it is a completely separate entry in the database with its own menu title, page file and content ID's.

So i need a way to link the different pages together as being the same page but in different languages. a way for the admin to note which pages are the same and for the system to load the correct page in the other language when the user clicks the flag.

Thank you
Thomas

site | blog | iphones |
 
You can group them with the page name or even with a page_Id if you have another primary key .

That is all your say "home" pages would have the same ID, but a different language_id.

So querying for "home" would yield all the home pages you currently have with all their languages.



Code:
general_id, page_id, page_name, language_id
0             01        home       eng
1             01        home       fra
2             01        home       ger 
3             02        about      eng
4             02        about      ger
5             03        services   eng

Kind of like that.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
so the shared secondary ID would be the best way, i thought as much. Just need to find the best way for letting the admin decide what pages match which pages in other languages without leaving too much room for human error, always the tricky part >.<
Thanks for your input :)

site | blog | iphones |
 
why have a second ID? why not just make the primary key a combined key of pageId and language?
 
the primary is an autoincrement id which is a bit easier and stable in management.

if the user adds a menu in language X but does not select that it belongs in the same pool as menu id 1 from language Y then the new menu would get id 2. then if he later corrected it to match the other menu it would change the id to 1. making a mess with any tables linked to that specific menu id. easier to keep all the links on 1 id that will not change and add a secondary "pool identifier".


site | blog | iphones |
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top