RTLing OpenCart Default Theme

OpenCart is a powerful open source shopping cart system. It has many features that enables you to setup your e-commerce business easily. Although the system is multilingual and templatable, its default theme doesn't support RTL. Here's how to add it..

1. Set your language to an RTL one

  • We'll go for Arabic. Go to your Admin Dashboard, go to the Languages page through the System > Localization > Languages, then click Insert to add your new Language. Below is how I added the Arabic language
    Adding the Arabic Language in OpenCart  
  • Go to your language folder in <opencart_root>/catalog/language. It should include at least the english folder; copy  that folder to another one named arabic, and rename the english.php file in the new folder to arabic.php (as we specified the Directory and Filename in the previous step)
  • Open the newly renamed arabic.php file to find a list of localized variables. In our RTLing process, we only care about the direction which can be found at line #4 as:
    $_['direction'] = 'ltr'

    change the value to be:

    $_['direction'] = 'rtl'

    and also update the

    $_['code'] = 'en'

    to be

    $_['code'] = 'ar'
  • Now go to your Front End to make sure it's working, you'll see the language selection now includes both languages and the Arabic version now only flips the text direction. That is because the template added the dir='rtl' in the html based on the $_['direction'] = 'rtl' in our language installation.

2. RTL the theme

Now that we prepared our multilingual OpenCart system. It's time to make it multidirectional.

  1. Open the default theme directory. It's at <opencart_root>/catalog/view/theme/default/
  2. In the stylesheet folder, you'll find 2 CSS files: stylesheet.css and ie6.css. Copy these to rtl.stylesheet.css and rtl.ie6.css respectively and RTL the directional rules while ommiting the non directional ones ( e.g display:inline; ). (use the third method explained in the tutorial on how to RTL your CSS).

3. Enable the RTLed theme

Once you're done, all what we have to do is including these RTLed CSS in the template when an RTL language is being used. This is usually done in the ,<head> section. So..

  1. Open the header.tpl file that can be found at <opencart_root>/catalog/view/theme/default/template/common/
  2. You'll find that the stylesheet.css is being added at line #19. Add your RTLed file after it if the direction is rtl like this:
    
    
       
    
    
  3. Apply the same method to the ie6.css link at line #21 like this: 
    
    
       
    
    

4. Enjoy it!

And that's it =) You can download the RTLed default theme(but not localized) below. Should you find any bugs or better suggestions on how to achieve this, please do mention it in the comments form below.

Note:There are some cool folks who localized the whole thing to Arabic over here. But it totally replaces the default theme to strictly use the RTL layout and you can't use the theme in a multilingual site. You can use their language files with the theme we just RTLed to get a multilingual and bidirectional theme

Average: 2.6 (37 votes)

Comments

how u handel this

<?php foreach ($styles as $style) { ?>
<link rel="<?php echo $style['rel']; ?>" type="text/css" href="<?php echo $style['href']; ?>" media="<?php echo $style['media']; ?>" />
<?php } ?>

thx very match ..

i like ALL u post .. Good JOOB

For almost ten years of providing excellent and exceptional product or service for the people in the United States and also the remaining people world wide, Acorn Stair Lift Incorporated has received an admirable rapport
to clients or buyers of stairlifts and other connected products.
Other times it's actually a flaw or crack that could
be fixed. Idea 1 - Remodel in, not out - Don't blow out a corner or side in your home using a big fancy addition (until you wish to live there many years).

excellent points altogether, you simply won a new reader.
What would you suggest about your put up that you just made a few days in the past?
Any positive?

I'm impressed, I have to admit. Seldom do I encounter a blog that's both equally educative and entertaining, and without a doubt, you've hit
the nail on the head. The problem is something which too few people are speaking intelligently about.

I am very happy that I found this in my search for something
regarding this.

Much of what fasters bemoan about their habits in Ramadan is the few hours after
fetar when they turn into sedentary slobs, sedately coiled into one corner of the
couch, shuffling channels launched solely for their entertainment during the holy month.
A Palestinian man hangs decorations for the upcoming
holy months of Ramadan outside his home in Jerusalem's Old City
on July 31, 2011. These Islamic books are meant for the age group 7-10 years.

This is a very good article thanks
But what about if i am using multilingual website, I have two buttons select english and arabic laguages. how do i call only stylesheet.css when a user clicks on english buttonand both stylesheet.css and rtl.stylesheet.css when a user clicks on arabic button?

A Bible verse that is misquoted so many times comes to mind:
. Today, especially during our challenging
economic times, invoice factoring services can be a beneficial tool for business owners worldwide.
Whatever your business does, there will be a way for you to measure the influence of social media.

If the reception is being held in the same place as the wedding,
you may write: reception to follow. Reply to each question to the best of your
capability. One of the first golfing rules of etiquette and a very important one at that is -"To learn to play properly before going out on the golf course".

If the reception is being held in the same place as the wedding,
you may write: reception to follow. Reply to each question to the best of your
capability. One of the first golfing rules of etiquette and a very important one at that is -"To learn to play properly before going out on the golf course".

Hello my loved one! I wish to say that this post is amazing,
great written and include almost all significant infos. I would like to see more posts like this
.

I enjoy reading through a post that can make men and women think.

Also, many thanks for allowing me to comment!

Excellent site. Plenty of helpful information here.

I am sending it to a few buddies ans additionally sharing in delicious.
And naturally, thank you to your sweat!

Olá, adorei extraordinariamente do seu blog! achei o tema muito
bem alinhado. escrevi um website no mesmo assunto e gostaria de ver se você tem alguma sugestão para quem está começando a postar
arrigos sobre isso. Obrigado!

I am basically impressed with this particular blog and that I wished to take the time to thanks from
my heart's base!

If you wish to make exztra Adsense money, you then'll have to work smarter
and tougher.

The message from this fantastic book is not to live a life of scrimping if it doesn't make you happy.

lrz formats some of the other sites that have free
e - Books might not be immediately compatible.
This book contains no technical theories and really focuses on how NOT To lose money.

It's hard to find knowledgeable people about this topic, but you sound
like you know what you're talking about! Thanks

Once you have this you'll be able to then enter this within the
MAC deal with safety space on your WiFi router.

When the S&P 500 broke above 2000 it entered a level research suggwsts could contain a large pullback.
Being sso they are worth reading about and
taking note of. Investors thinking about buying the best
organic food stocks should first make sure that they understand what the term
organic means.

Desalniettemin eventjes wat hierover completeren. Is
iets betreffende trap lifen.

Woman being a carved sculpture of Almighty, do have urge for sexual pleasure, in fact healthy sexual
life is equally important for a woman to induce impetus for a long and reliable relationship.
They attach to the man's genitals, and to the personal
computer via USB. To get more softball training aids
such as softball pitching aids, please visit.

For example, one segment asked the contestants to write Yelp reviews
for a strange orgy-like scenario in a music video. Proper stretching can't be
missed after each practice or game. Finally, Rosie Huntington-Whiteley-British model and actress-shared plenty of up close and personal images on social media.

Hi Dear,
first thanks for your learning.
i select my rtl language and my details is the $_['code'] = 'fa'; $_['direction'] = 'rtl'; then follow your way but when i echo $direction in header.tpl shown ltr. i dont know why the current language is ltr !! :-(

Can you help me for it ?

Thanks.

Thanks for every other magnificent post. Where else
could anybody get that kind of info in such an ideal means of writing?
I've a presentation next week, and I am on the look for such information.

Selecting a trade that will multiply your trading balance is just not much harder than being profitable with a regular trade.
Unlike other ttypes of options, all that traders need to
do is call their strike price, which is the point aat which they predict their asset
wijll settle on the expiratiuon date, and they will
receive a return if they are correct. Registered brokers arre often subjected tto periodic inspections to ensure that they are playing by the rules.

Make sure you go through the features offered by the device and
understand its specifications like processor type, speed, screen resolution, image format it supports, audio & video support
etc. Make sure you pay attention to a game's rating when buying a gift.

You can read game reviews, download games and play them online.

I'm really loving the theme/design of your weblog. Do you ever run into any internet browser compatibility issues?
A number of my blog readers have complained about my website not working correctly in Explorer but looks great in Opera.
Do you have any tips to help fix this issue?

Hello! This is my first visit to your blog! We are a team of volunteers
and starting a new initiative in a community in the same niche.
Your blog provided us beneficial information to work on. You have done a
extraordinary job!

Add new comment

Twitter Updates

Recent comments

Who's online

There are currently 0 users online.