How to make a specific post RTL? I have a page where i post English articles by default. but sometimes I have a Persian article that should be posted inside this page. After posting, it shows left to right and is very bad looking. specially if there is bullet points included in the articles. I want to know if there is a module for this or a way to edit my theme files.
Basically what you want to do is conditionally add a class to the field that aligns text to the right. I was wrong in my comment about hook_page_alter, I don't believe it has access to everything you need.


set up a new field, called field_content_persian, check boxes/radio buttons, valued English and Persian, default to English
in Manage Display, hide the label, and move the new checkbox field ABOVE the body. It must render first for this method to work
add CSS - ie. style.css

.align-text-right{
  text-align:right;
}

to template.php add:

function THEMENAME_field__field_content_persian__CONTENT_TYPE_MACHINE_NAME($vars){

  if($vars['element']['#items'][0]['value'] == 1){
    drupal_static('isPersian', true);
  }
  return "&lt;!-- empty --&gt;";
}

function THEMENAME_field__body__CONTENT_TYPE_MACHINE_NAME($vars){

  if(drupal_static('isPersian'))
  {
    $vars['classes_array'][] = 'text-align-right';
    $vars['classes'] .= ' text-align-right';
  }
  return theme_field($vars);
}


If you have a theme named Bartik, and a content type named Article, they would look like this:

Bartik_field__field_content_persian__Article() and

Bartik_field__body__Article()


What this does:


in the first function (field_content_persian), it checks for the value of the checkbox, and if it finds it is 1(persian if order of elements in checkbox is correct - modify as desired), it sets a temporary static variable. Then it returns an empty string so that the field itself doesn't display - NOTE: this function MUST return something, anything, or Drupal will bypass the function and call the default
in the second function it checks for the variable, and if it finds it, adds the class to the body field.