Results 1 to 8 of 8

Thread: The same news archive on two language websites.

  1. #1
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default The same news archive on two language websites.

    Hello,

    I will try to explain my problem as clear as I can.

    I've created two versions of the website (Serbian Cyrillic /*fallback language*/ and Serbian Latin).

    Now, I have to use the same news archive on both websites without changing global language variable $GLOBALS['TL_LANGUAGE'] value. Is that possible at all?

    I was thinking to change the news item link depending of active language $GLOBALS['TL_LANGUAGE'] but I can't find where it is generated:

    Something like this:

    Code:
    if lang = lang1 
    then href = .../news-lang1-page/news-title
    else href = .../news-lang2-page/news-title.
    
    /*showing news item from the same news archive*/
    where news-lang1 and news-lang2 are pages where news readers are located.

    I am trying to avoid creating separate news archives, because the language is the same, I just need to convert strings from Cyrillic to Latin with function I made.

    As I understand, by default, separate news archives have to be created for different language websites.

  2. #2
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    You're only talking about news archive, but there are Newslist, News reader, News archive and News archive menu.

    If you only want News archive, that is simple - include the same module on both pages. (Make a linked content element type content element for the second language.)

    Page en - CE type Module (Fallback tree)
    Page de - CE type Content element (links to CE above)

    If you have other modules, maybe a reader, try to give the reader pages in both trees the same alias, sometimes this is all you need.

    In your template you can get the language of current page with
    PHP Code:
    echo $GLOBALS[TL_LANGUAGE]; 
    Or you can get more details about the page with
    PHP Code:
    global $objPage;
    echo 
    $objPage->alias;
    var_dump($objPage);
    // or with
    echo $this->getPageDetails([yourPageID])->alias
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  3. #3
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Hello, Andreas.

    You have guessed right. Actually, I managed to get newslist, news archive menu and news archive to work. The newsreader remain to be a problem, but I will try what have you suggested and I will report it here.

  4. #4
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Quote Originally Posted by Andreas View Post
    If you have other modules, maybe a reader, try to give the reader pages in both trees the same alias, sometimes this is all you need.
    I tried this, but with no success.

    Page alias couldn't be changed to the existing value using Backend settings (it asks for unique alias). But, I use phpmyadmin and I was able to change it manually. But, It hadn't help.

    The problem is that when I click on "Read more" link, whether it is from Newslist or News archive, it forwards me to the page which belongs to the main language - fallback tree.

    E.g. - one news item is shown on the page as:


    Code:
    <div class="layout_simple block<?php echo $this->class; ?>">
    <?php if ($this->date): ?><time datetime="<?php echo $this->datetime; ?>"><?php echo $this->date; ?></time> <?php endif; ?><?php echo $this->linkHeadline; ?> 
    </div>
    produces

    Code:
    <div class="layout_simple block first even">
    06.10.2015<br><a href="index.php/news/this-is-a-text-headline" title="Full article">This-is-a-text-headline</a> 
    </div>
    So, I guess I have to find way to manipulate with $this->linkHeadline depending of variable $GLOBALS[TL_LANGUAGE].

    But on another hand, I am thinking it could be more easier to introduce one new session variable without the second tree, and change the news templates?!

    Code:
    if $SpecVariable='sr-lat' echo function_cyr2lat($this->text) else $this->text

  5. #5
    User Spooky's Avatar
    Join Date
    01-03-13.
    Posts
    339

    Default

    First of all, you should be able to use the same Alias if you either use different Domains or you are using the same Domain, but different languages and you are using the language fragment in the URL.

    Secondly, you could simply create your own news_latest Template and build the URL to the correct Reader Page manually.

    You could also do this in a parseArticles Hook. In this Hook you simply check for the current language and then change the linkHeadline, more, etc. variables of the news entry to point to the correct news reader page.

  6. #6
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Quote Originally Posted by tetrijeb View Post
    Page alias couldn't be changed to the existing value using Backend settings (it asks for unique alias). But, I use phpmyadmin and I was able to change it manually. But, It hadn't help.
    As spooky told already you are able to set the same page alias in different "Website roots". Check again why this is not possible. Never do change a value in the DB manually!

    You also can post a link to the page so help will be more easy for us.
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

  7. #7
    User tetrijeb's Avatar
    Join Date
    04-19-12.
    Location
    Bosnia&Herzegovina
    Posts
    114

    Default

    Well, my first association after I have read Spooky's post and went to check my settings in Backend was that cartoon with little Sylvesters son (if someone watched this):



    Quote Originally Posted by Spooky View Post
    First of all, you should be able to use the same Alias if you either use different Domains or you are using the same Domain, but different languages and you are using the language fragment in the URL.
    After I noticed that I didn't check the option "Add the language to the URL", I did that - and now it works!

    Since I didn't checked language URL, both language URL was the same, so I wasn't be able to give the same alias to the page. Now I succeded, and news reader is working.

    Quote Originally Posted by Andreas;
    Never do change a value in the DB manually!
    It was just an experiment. After that I returned it to the original state. However, I have to say to anyone who read this - don't try it at home.

    To sum up (for someone who could need to make something similar in in future):

    - I have created function that is replacing output string characters (Cyrillic to Latin and vice versa). Function checks the language parameter of the page.
    - I modified Contao templates I use so wherever some output text is printed from the database, I use function to check whether text should be transliterated.
    - I have created 2nd website root (with copies of all pages from the fallback language root) with different (new) language parameter
    - I have used [changelanguage] extension from Catalog Manager to make "language switch" in Front End

    There are some things I have to clean up, like some page links that I manually created in some parts of website, some templates adjusted, etc., but in general, it works now.

    Thank you, Andreas and Spooky. One thing is sure, I wouldn't figure out this without your help.

  8. #8
    User Andreas's Avatar
    Join Date
    07-11-09.
    Location
    Mönchengladbach
    Posts
    499

    Default

    Quote Originally Posted by tetrijeb View Post
    - don't try it at home.
    ROFL

    Nice to see that it works
    Web-Development, Freelancer, Burgtech, XHTML, HTML5, CSS, PHP, Javascript, MooTools, MySQL and more
    Amazon wishlist

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •