CMS MADE SIMPLE FORGE

Babel: Multilingual site

 

[#4782] Compatibility with News module (and possibly others)

avatar
Created By: Ludovic LANGE (llange)
Date Submitted: 2010-04-12 12:55

Assigned To: Ludovic LANGE (llange)
Resolution: None
State: Open
Summary:
Compatibility with News module (and possibly others)
Detailed Description:
Hello everybody,

Based on your experience, how do you use Babel with the News module ?

(The problem I have : the links generated by the News module are relative to the
root of the web site. And, the .htaccess / rewriting consider the first path -
/news/ - as a language)

(I think the problem may not be limited to the News module.)

One way I can think of is tweaking the Rewrite expression and conditions in
.htaccess.

The way I tried to solve it was with a patch to the news Module :

============
Index: 1.6.x/modules/News/action.default.php
===================================================================
--- 1.6.x/modules/News/action.default.php       (revision 365)
+++ 1.6.x/modules/News/action.default.php       (working copy)
@@ -346,6 +346,13 @@
       {
        $prettyurl .= '/d,' . $sendtodetail['detailtemplate'];
       }
+
+       /* For BABEL multilingual site */
+       $page_lang_info = $smarty->get_template_vars('page_lang_info');
+       if( isset( $page_lang_info ) && !is_null( $page_lang_info ) ) {
+        $lang = $page_lang_info["langcode"];
+        $prettyurl = $lang . "/" . $prettyurl;
+       }
 
$sendtoprint = array('articleid' => $row['news_id'], 'showtemplate' =>
'false');
 
============

This patch should work with or without pretty urls, but was only tested with
pretty urls.
Also, it should work on non-babel installs also, but I didn't try neither.

Please give me some feedback on this and how you use babel / news.

History

Comments
avatar
Date: 2010-04-12 14:30
Posted By: Pierre-Luc Germain (plger)

Are you using different news categories for different languages?
      
avatar
Date: 2010-04-12 14:33
Posted By: Ludovic LANGE (llange)

Yes,
I have a "francais" category for fr_FR, and an "english" category for the other
languages.
Ex:
{news lang=$page_lang category="francais"}

{news lang=$page_lang category="english"}
      
avatar
Date: 2010-05-30 05:33
Posted By: Bernd Klenk (klenkes)

Ludovic... I love you!
And Pierre-Luc anyway!

I was looking for a solution to this for a long time now and your patch works
perfect.
This is extremly useful for me since I am doing a lot of Smarty regex_replace in
URLs in the search resulttemplate to serve correct URLs to the pages where the
content actually lives on, and now I am able to filter newslinks for languages
as well.
Great!
      
avatar
Date: 2010-05-31 14:16
Posted By: Bernd Klenk (klenkes)

mhh... me... jumping the gun again!
As I found out today: it doesn't affect the searchresult URL. At least I am not
back to square one... only square two ;-)
      
avatar
Date: 2011-10-22 12:42
Posted By: Louis-Philippe Day (ataxel)

Do you think it can work with CGCalendar. I have the same problem. . .