PunBB Resource

Your ultimate PunBB resource!

Keywords:

    (Extended)

You are not logged in.

#1 2007-01-09 00:03:48

-J-
Member
Registered: 2005-05-24
Posts: 27

categories, languages & parameters

Hi everybody,

Is there a way to associate a language to categories, and to display languages (and the associated) categories separately?

With nice rewriting rules I'd like to split my forum in 3 languages:

mydomain.net/forum/ -> in english
mydomain.net/forum/es/ -> in spanish
mydomain.net/forum/fr/ -> in french


Thanks a lot in advance for your help smile

J


I wish you an happy and healthy 2007!

Offline

 

#2 2007-01-09 12:41:49

elbekko
Moderator
From: Leuven, Belgium
Registered: 2006-01-31
Posts: 1353

Re: categories, languages & parameters

Rather doable I think. I'll take a look tonight wink
Do you know how to make the rewrite rules?


FluxBB
dictionary.com on programming: The most fun you can have with your clothes on (although clothes are not mandatory).

Offline

 

#3 2007-01-09 18:32:50

-J-
Member
Registered: 2005-05-24
Posts: 27

Re: categories, languages & parameters

Yes I should be able to make them, as long as we add a parameter to the URLs, such as

http://www.punres.net/viewtopic.php?id=2679&lang=en

Thanks in advance for your help wink

Last edited by -J- (2007-01-09 18:33:10)

Offline

 

#4 2007-01-09 19:05:45

elbekko
Moderator
From: Leuven, Belgium
Registered: 2006-01-31
Posts: 1353

Re: categories, languages & parameters

Righty, let's take a look then... viewtopic and viewforum should be modified...

Open viewtopic.php
Find

Code:

// Load the viewforum.php language file

After, add

Code:

if(isset($_GET['lang']))
    $pun_user['language'] = $_GET['lang'];

(note that this would be the exact language like PunBB uses them wink)

Open viewtopic.php
Find

Code:

// Load the viewtopic.php language file

After, add

Code:

if(isset($_GET['lang']))
    $pun_user['language'] = $_GET['lang'];

I think that should do it wink


FluxBB
dictionary.com on programming: The most fun you can have with your clothes on (although clothes are not mandatory).

Offline

 

#5 2007-01-09 22:23:15

-J-
Member
Registered: 2005-05-24
Posts: 27

Re: categories, languages & parameters

Thanks for the input smile

That code changes the current forum language, doesn't it?

Is it possible to affect languages to categories/forums and %$* ...

an example/text-mode-schema would be probably better to explain what I'd like to do smile

Category 1 [english] I love punBB!
    forum  1 [english] news
    forum  2 [english] discussions
   
Category 2 [spanish] Quiero punBB!
    forum  3 [spanish] novedades
    forum  4 [spanish] discussionnes

Category 3 [french] J'aime punBB!
    forum  5 [french] Nouveautes
    forum  6 [french] Discussions


then  www.mydomain.net/forum/en/ would display
Category 1 [english] I love punBB!
    forum  1 [english] news
    forum  2 [english] discussions

and the board language would be in english


www.mydomain.net/forum/es/ would display
Category 2 [spanish] Quiero punBB!
    forum  3 [spanish] novedades
    forum  4 [spanish] discussionnes

and the board language would be in spanish


www.mydomain.net/forum/fr/ would display
Category 3 [french] J'aime punBB!
    forum  5 [french] Nouveautes
    forum  6 [french] Discussions

and the board language would be in french

add the ability to have several categories per language, and you've got an idea of what I'd like to get.

Is it possible to do such a thing?

Thanks so much!

J

Offline

 

#6 2007-01-09 22:36:51

elbekko
Moderator
From: Leuven, Belgium
Registered: 2006-01-31
Posts: 1353

Re: categories, languages & parameters

Ah, I see... that's a tad harder tongue

Try making a separate file called langchoose.php or something. Put in a switch getting the $_GET['lang'] var and redirect to the right category/forum (for a category, try using this: http://wiki.punres.net/Show_category). For the language: keep passing the lang variable through GET and put the code I posted above in common.php or so, so it'll select that lang on each page.


FluxBB
dictionary.com on programming: The most fun you can have with your clothes on (although clothes are not mandatory).

Offline

 

#7 2007-01-09 23:01:12

-J-
Member
Registered: 2005-05-24
Posts: 27

Re: categories, languages & parameters

elbekko wrote:

Ah, I see... that's a tad harder tongue

Yes it is big_smile

It's gonna take me a while to do that. I'll try to get some time next week end, if you've got more ideas/suggestions, please let me know smile

edit: the main idea is to make 3 forums (one per language) using punBB's core wink exciting, isn't it?

Last edited by -J- (2007-01-09 23:02:47)

Offline

 

#8 2007-01-09 23:06:17

elbekko
Moderator
From: Leuven, Belgium
Registered: 2006-01-31
Posts: 1353

Re: categories, languages & parameters

If you do it my way, you should be fine tongue


FluxBB
dictionary.com on programming: The most fun you can have with your clothes on (although clothes are not mandatory).

Offline

 

#9 2007-01-09 23:24:23

-J-
Member
Registered: 2005-05-24
Posts: 27

Re: categories, languages & parameters

where/when langchoose.php would be called?

shouldn't I modify the "category table" in database to add a category_lang etc ..., and modify the sql query here http://wiki.punres.net/Show_category to return all categories where category_lang=$_GET['lang'] ? or a kind of thing like that?

Oh dear, I see it more complicated?!

Last edited by -J- (2007-01-09 23:24:41)

Offline

 

#10 2007-01-09 23:33:02

elbekko
Moderator
From: Leuven, Belgium
Registered: 2006-01-31
Posts: 1353

Re: categories, languages & parameters

No, you just create a new category (and the forums for it), and make langchoose.php redirect you to the correct URL to index.php. It should only be called once I think.
Maybe store the lang setting in a session even?


FluxBB
dictionary.com on programming: The most fun you can have with your clothes on (although clothes are not mandatory).

Offline

 

#11 2007-01-10 13:43:45

-J-
Member
Registered: 2005-05-24
Posts: 27

Re: categories, languages & parameters

a couple of questions:

1. about langchoose.php, where in the code is it called? is it a file included in index.php or something like that?

2. is there a way to display several categories with "showCategory"?

Offline

 

#12 2007-01-10 15:37:45

elbekko
Moderator
From: Leuven, Belgium
Registered: 2006-01-31
Posts: 1353

Re: categories, languages & parameters

-J- wrote:

1. about langchoose.php, where in the code is it called? is it a file included in index.php or something like that?

No, it's a file with content like this:

Code:

<?php
session_start();
switch(@$_GET['lang']) // This was passed through .htaccess
{
    default:
    case 'en':
        $_SESSION['lang'] = 'English';
        header('Location: index.php?cat=1'); // The english category
    break;
    case 'sp':
        $_SESSION['lang'] = 'Spanish';
        header('Location: index.php?cat=2'); // The english category
    break;
    case 'fr':
        $_SESSION['lang'] = 'French';
        header('Location: index.php?cat=3'); // The english category
    break;
}
?>

and in common.php you'd put something like this, which would make sure that the chosen language is used throughout the forum:

Code:

session_start();
if(isset($_SESSION) && array_key_exists('lang', $_SESSION))
    $pun_user['language'] = $_SESSION['lang'];

2. is there a way to display several categories with "showCategory"?

Nope.


FluxBB
dictionary.com on programming: The most fun you can have with your clothes on (although clothes are not mandatory).

Offline

 

#13 2007-01-11 13:25:17

-J-
Member
Registered: 2005-05-24
Posts: 27

Re: categories, languages & parameters

Thanks elbekko for your help!

I definitely need a couple of days to deeply analyze punBB smile

Offline

 

#14 2007-01-11 17:03:40

elbekko
Moderator
From: Leuven, Belgium
Registered: 2006-01-31
Posts: 1353

Re: categories, languages & parameters

No problem, happy to help smile


FluxBB
dictionary.com on programming: The most fun you can have with your clothes on (although clothes are not mandatory).

Offline

 

Board footer

Based on PunBB
© Copyright 2002–2005 Rickard Andersson

© Copyright 2004–2006 Kristoffer Jansson

User contributed files are property of their respective owners.