Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: How to tell Arabic Pages to use RTL template not LTR template?

Status Resolved
Add-on / Version Publisher 1.6.2
Severity
EE Version 2.9.2

Gavin Lawrie

Mar 22, 2015

Apologies if answer to this is obvious - but I cannot find it in documentation.  I’m guessing I’m not the first person to want to do this, and imagine Publisher is able to do this, I just cannot work out how to get it to work on my site.

My site has three languages, one of which is Arabic. 
Content for Arabic is RTL, and to get layout looking OK I have specific alternative templates to make content work in RTL format.
I cannot work out how to coerce EE to use them when language is set to Arabic.
Currently everything is displaying using the default templates.

I’m hoping I’ve just missed something; it would seem sensible for Publisher to tell EE to use RTL template rather than LTR template when certain language group chosen.

Or is this best done some other way?

Thanks a lot for any assistance you can provide.

#1

BoldMinded (Brian)

Hi Gavin. Using an entirely different template is probably not the correct approach. You can use the {text_direction} variable noted in the docs: https://boldminded.com/add-ons/publisher/languages and use CSS to change the text direction. Or you can use {publisher:current_language_code} on your html body tag, and then use CSS to change the direction that way. http://www.w3schools.com/cssref/pr_text_direction.asp

#2

Gavin Lawrie

Thanks for speedy reply.

The issue is not about get text to display in RTL vs LTR, but how to change the layout according to whether it is RTL or LTR.

After discussion with users of our site in Middle East the suggested that elements of our layout need to be changed to accommodate RTL reading of our site - so for example floating menus appearing on right of text blocks not left, navigation icons that appear at the end of line in LTR should appear at start of line in RTL, the main menu starting its sequence from right not left and so on. Plus all the fonts we use on text need to be changed on arabic pages.

I realise that some (but perhaps not all) of these changes could all be implemented using convoluted CSS calls, but this would make the page design very complicated. It appeared easier to simply have one set of templates for arabic and another for LTR languages. But this relies upon their being a way to load a specific template set when arabic is chosen language rather than the default.

I had imagined this would be a common problem for developers wanting to build sites that work in both RTL and LTR - but perhaps not.

Can you think of any way I can achieve this template switching in EE based on the Publisher language selection in force?

#3

BoldMinded (Brian)

Publisher can’t handle templates for different languages. Have you tried a container template? E.g. if you have layouts/page.html as a template put only this in it:

{if publisher:current_language_code == 'ar'}
    {embed="layouts/page_ar.html"}
{if:else}
    {embed="layouts/page_default.html"}
{/if}

You’ll have more template files, but the main containers should be small with only a conditional in it. You may have to add conditional elsewhere depending on the complexity of your site, but checking that current_language_code variable may be your best bet.

#4

Gavin Lawrie

Ahah - that would be perfect! I’m not sure why I didn’t think of that, but am very glad that you did. Many thanks!

Login to reply