Drupal different theme for arabic and english - drupal

I created a drupal website in English, now i want to add an Arabic version to this site. I have added and enabled the i18n modules and now i have language switch options in my content creation and editing page in the admin.I want to show different themes for English and Arabic(for example mytheme and mytheme-ar). But how can i set drupal to show themes according to the URL , for example to show mytheme-ar, when the URL is example.com/ar and to show mytheme when example.com.
Can anybody suggest a solution? I have tried setting a cookie and setting the theme from includes/theme.inc according to the cookie. But I think there will be a more direct solution for this.

Take a look at the ThemeKey module. It can change the theme determined by complex (or simple) rules you create.

Related

Wordress - How to work with non wordpress theme

I'm new to wordpress, and I want to know if it is possible to put a theme bought on shapedtheme.com for example on an existing wordpress.
And if so, how to do it. I don't know where to put the code of the theme. I saw the wordpress page builder with text, but I see tags with [] and not <>.
I saw on this thread that pages can be linked to php files. I don't see how.
I have full access to the hosting service's filesystem and can see all wordpress files.
I would also like to transpose the theme header and footer and if possible, use the theme cards to adapt to blog articles written in wordpress.
How can I do this ?
I searched for tutorials on google or related threads on SO with no luck.
Any ressource would be appreciated.
Thanks to anyone who will take the time to read/answer this post.
No, you can't use a non-WordPress theme in a WordPress installation since WordPress will look for specific templates and pass certain objects to the template to be displayed.
You could adapt it to work with WordPress, though. Here's the theming guide to get you started.
But you'll probably be able to find a WordPress-ready theme with the features you want. This is the WordPress theme directory link for themes using bootstrap.
Unless you go for a from-scratch development of a pure php theme, and you need some level of theme customization I'd strongly suggest looking into child themes, as it'll allow you to update the base theme minimizing the changes you'd have to do to yours.
The [ ] syntax you mention are shortcodes, small, safe php functions that can be executed by inserting them in the editor, templates, etc, and provide kind of an api that exposes WordPress or plugins functionality.
And regarding your link, OP already has a WordPress theme, but is looking for a way of using a different, specialized template on specific pages. This template still has to follow to certain WordPress conventions.

Language switcher in wordpress

I'm looking for a simple plugin for WordPress to be able to switch the language on the front-end.
I tried many plugins no one worked. I just need to prefix my page path with something like /en/my_page and transform it to /fr/my_page when I select French as the current language for instance.
I also have spent in the past quite a lot of time looking for a plugin to create sites in various languages.
The only plugin I would recommend is Qtranslate https://wordpress.org/plugins/qtranslate/
Its very simple, and easy to customize the front-end template using shortcodes.
I have developed a free plugin for that purpose here:
https://code.recuweb.com/get/language-switcher/
It has been reviewed and hosted by Wordpress here:
https://wordpress.org/plugins/language-switcher/
Language Switcher allows you to map urls of alternative languages for Post Types and Taxonomies. Additionally it allows you to filter archive pages by language.
To prefix your pages with the language code I recommend you to follow these steps:
create a main page with slug en and another one with slug fr.
set my_page with parent page en and ma_page with parent page fr.
map the urls of the translations in my_page and ma_page
add the shortcode [language-switcher] to allow readers to jump from one page to another

WordPress Multi-site with Multi-language using WPML

I have a project with WordPress for a multi-language, multi-country site.
I want to have a structure like:
domain.com
domain.com/es
domain.com/de
domain.com/fr
domain.es
domain.es/en
domain.fr
domain.fr/en
domain.de
domain.de/en
I was wondering if anyone had any useful articles, tips or insights. The idea is that the .com site be the 'parent' site. The other satellite sites would be in their native language by default, but might have other languages available. Ideally, each individual satellite site could have some leeway to have styles/content that would be different than the parent site.
I also want the parent site to use canonicalization, so that the 'satellite' (country-specific, top-level-domain) sites have priority.
I guess I'm most curious to know about:
Domain mapping and compatibility with WMPL
Thanks
I use "Polylang" in all my projects and it works perfect for me. Polylang does 2 things:
1) Creates siblings for post and pages, connected through ID, so you may write a post in english and then a "spanish sibling" with different contents but connected to the other, so when you do the language switch it displays the desired languahe.
2) Automatically creates a sub route in your WordPress URL (like yourdomain.com/en and yourdomain.com/es) so it matches and changes the desired language interface. You may even use functions on your templates to switch some contents by language on the same template file. You may add and define as many languages as you want.
Important: this is not a plugin for "auto translate" contents, its more like an option to create multilingual sites.
You may find Polylang here: Download Polylang from WordPress Plugins
If you're interested on using Polylang on your templates, here you could find a solution for calling different contents according to the language selected by the user: Multiple headers by language using Polylang
I hope this work for you.
Greetings!
I want to like WPML because I purchased it, but it just never works well for me and I always end up using Polylang.
update I recently used WPML for project and the latest version worked extremely well for me. Polylang is still great and my latest experience with WPML is even better than Polylang.

In Drupal 7, I've created a subtheme, how do I assign that theme to a particular page?_

So I have my parent theme and my subtheme both enabled in Drupal 7.
I've specified in the .info of the subtheme that the base theme is the parent theme.
Once I create a page, how do I tell that page to inherit my subtheme?
Any help would be greatly appreciated.
EDIT:
So what I want to do is create several new pages (about 20) that are going to follow the same template file as the rest of my Drupal site. However, they are all going to have different background images, link colors, and heading styles. I figured the Drupal subthemes would let me create a page that inherits the main stylesheet, but lets me modify it as needed for the new pages. Sounds like that's not what subthemes are for.
Thanks to Matt V:
Subthemes allow you to use an existing theme as the starting point for creating your own custom theme.
I may be wrong but if you want to implement different themes on different pages, it sounds like what your looking for is "hook_custom_theme", it's pretty straight forward, basically you just add:
function mymodule_custom_theme(){
//Some custom logic here
$node=node_load(arg(1));
if($node && $node->type=="my_custom_type"){
return 'my_custom_theme';
}
}
your return value must be a string that equals the machine readable name of the theme you're switching to...
re-reading your post, you may want to look into the template_preprocess_html and template_preprocess_page functions. Inside of these functions you can set and alter your template variables, i.e.
$vars['styles']=drupal_get_css();
once you've done that you could easily swap out css tags with a little bit of logic, this method would allow you to only use one theme with multiple css files....
to activate a subtheme, you need to enable it and set it as default.
The subtheme (or any theme for that matter) is for the site as a whole. To theme an individual page you could create a template for that specific page, or use the Panels module - there are many ways to skin a cat in drupal.....
here is some more info Drupal 7 theme system changes
By using themekey module you can achieve this
Refer http://drupal.org/project/themekey
To have your theme activated site-wide and used as default for ALL pages, you need to go in admin/appearance and activate your theme, and then click on the link beside the theme "Define as default".
To have your theme used on one specific page, that would be a bit trickier to do, just clarify if that is what you really wanted.

How to add theme settings to Zen-based themes?

I'm trying to place my own theme settings into a drupal subtheme. i've used the forms API in theme-settings.php but they are not showing up in admin/build/themes/settings/$mytheme. my theme-settings.php is uploaded here in case you'd like to see it.
what it does is choose vocabularies for categories and tags, making it easier to port wordpress blogs to drupal.
so, the thing seems to be in mytheme.info
it seems i need to place a default value here in order to have the settings saved.
but i guess it doesn't make any sense.

Resources