darkhoros VIP
Total posts: 152
23 May 2015 08:31

Hi, This question has 2 parts, for composite titles, how can I call the item id to br in front of another text field. this is the easy question.

The hard qquestion is, how to make this title multilanhuage, I have read the documentaion and understand how it works in paralles and mirrored, and I can translate field vallue, but what I cant figure out is, how can I make the titles multilingiual.

Help is appriciated like always. Thank you.

Last Modified: 17 Jun 2015


darkhoros VIP
Total posts: 152
23 May 2015 12:44

Hi, Testing this I found that all fields don't have a language restriction, i was planning to get 2 fileds inserted by users in form submission for types, and using language restrictions get viewd each in corresponding language, any idea no how to implement such setting? Thank you.


darkhoros VIP
Total posts: 152
24 May 2015 11:40

Hi, In my efforts to get this title issue resolved I have made a setp further, I have created a text field for english titles and text field for arabic titles, then I made the title unique with composite titles and makeing the following pattern

english title | english arabic

then I will use the php explode using the "|" as delimiter so I get the arabic text separated from english text, then using conditional statment for language I can controller the part of title to print, question is, where and what file do I add this explode function to and what condition for language do I use?

I hope some one can shade some light on this issue. Thank you.


Sergey
Total posts: 13,748
25 May 2015 05:27

darkhoros Hi, Testing this I found that all fields don't have a language restriction, i was planning to get 2 fileds inserted by users in form submission for types, and using language restrictions get viewd each in corresponding language, any idea no how to implement such setting?

This is not how it works. Because it would save the same data diferently. For example you have values in German and English. One people save the same value of different languages and when you filter those will be different values. That is why in the fields you have to use language constants. That will ensure that no matter what language user use he will see those values in his language no matter on what language article was saved.

darkhoros how can I call the item id to br in front of another text field. this is the easy question.

Not exactly sure what you want. You mean ID of the article or ItemID of the URL? And where you want a BR in title or in template?

darkhoros The hard qquestion is, how to make this title multilanhuage, I have read the documentaion and understand how it works in paralles and mirrored, and I can translate field vallue, but what I cant figure out is, how can I make the titles multilingiual.

In your case youo should not use composite title parameters but you have to use manual composite title. It means that in parameters you may still have composite title just for yourself, but in the list of the records, it template you echo field by field in the position of the title.

So end user see the fully translated title and vendor only adds one field.


darkhoros VIP
Total posts: 152
25 May 2015 09:15

Dear Sergey, I hope you get time to read my post just before your post, I hope you can help me with it, I have managed to do the translation for all fileds and fields values, what is missing now is the title of article and page title.

Thank you.


Sergey
Total posts: 13,748
27 May 2015 16:21

I think I perfectly understood your problem. And I was telling that you cannot translate composite title. I mean may be you can with Falang or Jomfish it is still exists.

But what I offered is automatic title translation. When you composite title in template, it means that title is not saved, but created every time template is rendered. And since it composed of translated Cobalt fields, it will be also automaticaly translatable.

Please show me your composite title pattern you use in parameters I'll show what I mean.


darkhoros VIP
Total posts: 152
27 May 2015 20:36

Hi, this is the Composite title mask [15] | [16]

where 15 is text field for arabic and 16 is text field for english?

Do you like me to send you username/password of ttesting evironment?

If so , how do I private sms?

Thank you.


Sergey
Total posts: 13,748
01 Jun 2015 12:19

In article list anf full article template instead of title echo $item->title use somethign liek this.

<?php echo $item->fields_by_id[15]->result ?> | <?php echo $item->fields_by_id[16]->result ?>

For the end user it will lokks just like composite title, but it will be composed in template not on article save. And as a result it will be always displaied in current language without problems.


pepperstreet VIP
Total posts: 3,837
01 Jun 2015 22:49

darkhoros using conditional statment for language I can controller the part of title to print, question is, where and what file do I add this explode function to and what condition for language do I use?

I assume in your setup... you can't use the record's language field.
So, you might get the current site language instead. Then use the language tag or code for your condition:


darkhoros VIP
Total posts: 152
15 Jun 2015 09:43

Hi, ok I managed to do what is needed with the following code

$sitelang = $lang->getTag();

switch ($sitelang) {
                    case "en-GB":
                        echo JHtml::_('String.truncate',$item->fields_by_id[21]->result,$title_length);
                        break;
                    case "ar-AA":
                        echo JHtml::_('String.truncate',$item->fields_by_id[22]->result,$title_length);
                        break;
                }

But the browser title is showing the actual composite title with arabic and english parts as I lift the unique titles on in order to have the page url with both languages, but I need the browser title to be as same as the article title, which switchs between arabic and english. So where to do the change for the browser title to do the same effect. Thank you for your usual support.


Sergey
Total posts: 13,748
15 Jun 2015 11:07

You can add inside article full view template something liek this.

$sitelang = $lang->getTag();

switch ($sitelang) {
    case "en-GB":
        $t = JHtml::_('String.truncate',$item->fields_by_id[21]->result,$title_length);
    break;
    case "ar-AA":
        $t = JHtml::_('String.truncate',$item->fields_by_id[22]->result,$title_length);
    break;
}
JFactory::getDocument()->setTitle($t);

darkhoros VIP
Total posts: 152
16 Jun 2015 07:50

Perfect, Can this be pushed further and make same effect for the URL, so in arabic version the URL will contain the article arabic title and english version contain the english part only.

Thank you.


Sergey
Total posts: 13,748
17 Jun 2015 06:12

Yes you can do that. But my point was that if you use language keys in tyour fields like select, checkbox, ... all that should work out-of-the-box.

Powered by Cobalt