TinyPortal

Development => Support => Topic started by: Kordanor on June 20, 2009, 03:02:18 PM

Title: Language Specific Frontpage
Post by: Kordanor on June 20, 2009, 03:02:18 PM
Heya,

I have got 2 languages installed in the board and I already managed to include specific panels dependent on the language, so that newest articles are just shown from specific language boards.

But where I can't find a solution is the main window on the frontpage. Is it possible to show just posts of specific threads there dependend on the language selection?
Title: Re: Language Specific Frontpage
Post by: G6Cad on June 20, 2009, 07:59:05 PM
We need to know more about your setup to answer that question.

Please read the Posting Guidelines.html (http://www.tinyportal.net/index.php/topic,581) and uppdate your first post with the info we ask for in the posting guide.
Title: Re: Language Specific Frontpage
Post by: Kordanor on June 20, 2009, 08:07:42 PM
I don't really see a point in that as it is a general functionallity question but there you go:

Link to my site: http://ndnw.piranho.de/forum/index.php
(which wont work most probably as I am editing in it all the time)
SMF version: 1.19
TP version: v1.0 beta 4
Theme name and version: default...still modifying it myself
Browser Name and Version: IE 6.0 FF 3.0.11 Opera 9.64
Mods installed: None
Related Error messages: None
Title: Re: Language Specific Frontpage
Post by: G6Cad on June 20, 2009, 08:32:32 PM
With info we need more of i mean what you posted so we can see what you have so far.
And with more info i mean more info on your settings, what you have tried so far, if you are using blocks, or articles, or single pages etc.

More or less, what is your setup and what have you done so far with the settings.
Title: Re: Language Specific Frontpage
Post by: Kordanor on June 20, 2009, 08:42:13 PM
Well, maybe I just put my question not straight enough.

Is it possible without editing within the code to implement an alternative/additional frontpage which is getting other boards to display as news?

Lets say:

German Frontpage
getting news from boards 5,6,7 (which are german)

English Frontpage
getting news from boards 8,9,10 (which are english)

I could find enable/disable language options for the additional blocks and panels but nothing on the main "content" window.

If you say that there is no easy solution and I have to digg in the code, thats an okish anwer for me too, at least I know what to do then. :)
Title: Re: Language Specific Frontpage
Post by: G6Cad on June 20, 2009, 09:04:04 PM
AH!, now i see what you mean, i will have to let the coders answer this one as i dont know ( interested in the answers my self though )  ;)
Title: Re: Language Specific Frontpage
Post by: Zetan on June 20, 2009, 09:20:02 PM
Take a look in the Block Code Snippets board. Theres a snipet to show recent posts from boards, X, Y , Z. Then use it again for another article, show boards A, B, C.

It uses the ssi_recentTopics() and has the topics in an array.

http://www.tinyportal.net/index.php/topic,1234.0.html

Try changing

ssi_recentTopics

to

ssi_boardNews

It might just work.. I haven't tried it though.
Title: Re: Language Specific Frontpage
Post by: Zetan on June 20, 2009, 09:34:09 PM
Actually, all you should need is this:

Code (PHP Article) Select


$result=ssi_boardNews(10,array(1,3,4),'return');



let me know if it works, I may just use it myself.
Title: Re: Language Specific Frontpage
Post by: Zetan on June 20, 2009, 10:16:51 PM
Hmm.. after some testing, it wasn't that easy :P
have a look at this topic at SMF:

http://www.simplemachines.org/community/index.php?topic=163375.0



for TP php articles or blocks, the php tags are not needed

Code (php open tag) Select


<?php




Code (php close tag) Select


?>

Title: Re: Language Specific Frontpage
Post by: IchBin on June 20, 2009, 10:49:50 PM
There is no way to do this without modifying the code for articles. The only work around I would try is only using blocks on your frontpage. You can then control blocks with languages. And inside a blocks settigns you can show an article, and then select the language you want the block to show for.

Other than that, you would have to use some custom PHP code checking for a users language in the article.
Title: Re: Language Specific Frontpage
Post by: Zetan on June 20, 2009, 11:02:56 PM
My suggestion is pulling the ssi_boardNews from the language specific boards.

boards 1, 2 and 3 German,
boards 4, 5 and 6 English

The boards themselves will have the different languages.
Title: Re: Language Specific Frontpage
Post by: IchBin on June 20, 2009, 11:08:25 PM
But how do you control which user with a certain language gets to view those posts if you have it in an article?
Title: Re: Language Specific Frontpage
Post by: Kordanor on June 20, 2009, 11:46:24 PM
So you think, you should combine Zetans suggestion with the ssi option together with the block system?
Title: Re: Language Specific Frontpage
Post by: IchBin on June 21, 2009, 12:09:25 AM
You need to make sure you use the proper wording. There is a difference between articles, posts, and topics. When you said articles in your first post I thought you were talking about articles, and not posts or topics.

However, it sounds like all you need to do is combine both our suggestions to get what you want.
Title: Re: Language Specific Frontpage
Post by: Zetan on June 21, 2009, 06:52:39 AM
Quote from: IchBinâ„¢ on June 20, 2009, 11:08:25 PM
But how do you control which user with a certain language gets to view those posts if you have it in an article?

That is a good question!

It was late when I replied. I'd assumed Articles or the Article Categories have the same viewing options as Blocks. By current design, we don't have language viewing options in Articles.. But we do in blocks.

Example:

Title: Re: Language Specific Frontpage
Post by: bloc on June 21, 2009, 11:33:48 AM
ssi_boardnews can only fetch one board..but TP_boardNews can show multiple. Try in a single PHP block something like:


if($context['user']['language']=='english')
$myposts = TP_boardNews('12,15', 10,0);
elseif($context['user']['language']=='german')
$myposts = TP_boardNews('91,25', 10,0);

foreach ($myposts as $news)
{
echo '
<div>
<a href="', $news['href'], '">', $news['icon'], '</a> <b>', $news['subject'], '</b>
<div class="smaller">', $news['time'], ' ', $txt[525], ' ', $news['poster']['link'], '</div>
<div class="post" style="padding: 2ex 0;">', $news['body'], '</div>
', $news['link'], $news['locked'] ? '' : ' | ' . $news['comment_link'], '
</div>';

if (!$news['is_last'])
echo '
<hr style="margin: 2ex 0;" width="100%" />';
}


Note that the HTML code is just lifted from SSI, which may be different from TP usual output as TP use several layouts etc.

About articles being shown according to language thats something to be considered in future versions of TP.
Title: Re: Language Specific Frontpage
Post by: bloc on June 21, 2009, 11:36:00 AM
Note: this can actually also be used inside a regular PHP article, especially if you set as "featured" and show only that.
Title: Re: Language Specific Frontpage
Post by: Kordanor on June 21, 2009, 03:20:08 PM
Most probably the easiest methode would be to edit the code and just catch the language before the forums are selected, isn't it?

I guess it's done in the TPortal.template.php file, but i can't really find it.

My Idea is to do something like:

if (language==german)
{functiontogetthreads 5,6,7}
else
{functiontogetthreads X,Y,Z} //taken from settings, considered you make the main settings for english

The code is a little bit confusing, as I am not the only one who messed up articles and threads ;)
I mean even the print field is always called "print article", independet of the source.

Edit:
seems like the file is TPortal.php and the variable is $context
But I still can't make out the exact position.
Title: Re: Language Specific Frontpage
Post by: bloc on June 21, 2009, 06:11:29 PM
Uhm, try looking for this line:
$forumposts=TP_boardNews($context['TPortal']['SSI_board'],$maxnumber,$context['TPortal']['mystart'],$context['TPortal']['frontpage_limit_len'],'array');


As you can see its actually fetching posts from the TP setting of 5 boards. If we transfer what i wrote above to this, it would be:

if($context['user']['language']=='english)
$forumposts=TP_boardNews('12,15',$maxnumber,$context['TPortal']['mystart'],$context['TPortal']['frontpage_limit_len'],'array');
else
$forumposts=TP_boardNews('3,4',$maxnumber,$context['TPortal']['mystart'],$context['TPortal']['frontpage_limit_len'],'array');



It assumes its only english + another and will fallback on "other" if language for some reason is not defined.You could add another for guests as well if you like.

Note that the 5 boards setting in TP will not work now, it will only fetch the ones you put in. When you update TP this will be erased by newer files, so beware.
Title: Re: Language Specific Frontpage
Post by: Kordanor on June 21, 2009, 09:58:22 PM
Yep, works perfectly!

Thank you very much! :)