me321
posted this
26 September 2015
OK, I had another go at it and I've found a way to work around this issue and use templates created in Themler to be applied to your customer content types. It involves manually editing the exported files and this would have to be done at each export. Not ideal, but at least it will make Themler usable with Drupal in real life situations.
Basically this workflow creates a bit of what Artisteer did, a single template for all custom content types, although you could in theory have different ones for certain custom content types.
Here are the steps, in two parts:
PART 1
In Themler, style the "Post" template to your liking and so that it's universally usable by all your custom content types
Publish and export/ download your Drupal Theme
Open a proper text editor such as Sublime 3 or Notepad++
In the export directory, find the \themes[YOURTHEMENAME]\7.x\theme-methods.php file and open it with your editor
Find the line that contains the function [YOURTHEMENAME]_preprocess_page. In my case this was around line 29 but it may be different in your case.
Now we need to insert this bit of code inside that function:
if (isset($vars['node'])) {
$vars['theme_hook_suggestion'] = 'page__'.$vars['node']->type; //
}
so that as in my case, your function looks something like this (Don't copy the lines below, instead copy the lines above into your function yourself to make it just like the example below:
function YOURTHEMENAME_preprocess_page(&$variables) {
$node = isset($variables['node']) ? $variables['node'] : null;
YOURTHEMENAME_set_template($variables, $node, 'page');
$variables['tabs'] = menu_primary_local_tasks();
$variables['tabs2'] = menu_secondary_local_tasks();
$variables['search_box'] = NULL;
if (function_exists('search_box_form_submit')) {
$variables['search_box'] = drupal_get_form('search_form');
}
if (isset($vars['node'])) {
$vars['theme_hook_suggestion'] = 'page__'.$vars['node']->type; //
}
}
Save your file and upload it to your server, replacing the same file in your theme's remote directory.
PART 2
Go to the following directory inside your Themler theme download: \themes[YOURTHEME]\templates\page
The "Post" template you designed in Themler actually results in a .tpl file called page--node--article--XX.tpl.php (in my case XX was the number 6, but this might be different in your case.) Copy this file.
In the Drupal backend, check the machine name of your content type that you want to be using the design you created in Themler for the "Post" template. You can do this by navigating to /admin/structure/types and clicking "edit" for the content type in question and inspecting the machine name.
Now rename the file you copied in step 2 to match: page--node--[YOURCONTENTTYPEMACHINENAME].tpl.php
Upload your new tpl file to the same directory on your server.
Clear the caches in your Drupal site
Repeat these steps (of Part 2) for each custom content type you have in your Drupal site.
Dance!
Note that these steps need to probably be repeated each time your export your theme so you may want to really spend some good amount of consideration and time designing the layout of your "Post" template so that you don't have to alter it often. Minimize the use of any shared elements with other templates so it doesn't inherit changes you make to other templates as much. That way you can just keep a copy of your custom .tpl files and drop those in each new theme export and keep the code snippet from part 1 handy and paste it into your theme-methods.php each time you download a new version of your theme.
In the meantime, I'd like to suggest to the Themler team to make the "post" template apply to all content types, or introduce a new template type to act as a universal template for content types. The current "default" template applies only to pages that are not content/ nodes. So all content in the form of custom created content types basically are un-styled and have no layout and are outside of the Themler user's control. Once again, there's custom content types in pretty much every Drupal site. Modules (think: drupal commerce) also add content types and off course popular Drupal distributions (Commerce Kickstart, Spark, etc) all ship with their own content types, and right now Themler is basically incompatible with all of them.
OK, I had another go at it and I've found a way to work around this issue and use templates created in Themler to be applied to your customer content types. It involves manually editing the exported files and this would have to be done at each export. Not ideal, but at least it will make Themler usable with Drupal in real life situations.
Basically this workflow creates a bit of what Artisteer did, a single template for all custom content types, although you could in theory have different ones for certain custom content types.
Here are the steps, in two parts:
PART 1
1. In Themler, style the "Post" template to your liking and so that it's universally usable by all your custom content types
2. Publish and export/ download your Drupal Theme
3. Open a proper text editor such as Sublime 3 or Notepad++
4. In the export directory, find the \themes\[YOURTHEMENAME]\7.x\theme-methods.php file and open it with your editor
5. Find the line that contains the function [YOURTHEMENAME]_preprocess_page. In my case this was around line 29 but it may be different in your case.
6. Now we need to insert this bit of code inside that function:
if (isset($vars['node'])) {
$vars['theme_hook_suggestion'] = 'page__'.$vars['node']->type; //
}
so that as in my case, your function looks something like this (**Don't copy the lines below, instead copy the lines above into your function yourself to make it just like the example below**:
function YOURTHEMENAME_preprocess_page(&$variables) {
$node = isset($variables['node']) ? $variables['node'] : null;
YOURTHEMENAME_set_template($variables, $node, 'page');
$variables['tabs'] = menu_primary_local_tasks();
$variables['tabs2'] = menu_secondary_local_tasks();
$variables['search_box'] = NULL;
if (function_exists('search_box_form_submit')) {
$variables['search_box'] = drupal_get_form('search_form');
}
if (isset($vars['node'])) {
$vars['theme_hook_suggestion'] = 'page__'.$vars['node']->type; //
}
}
Save your file and upload it to your server, replacing the same file in your theme's remote directory.
PART 2
1. Go to the following directory inside your Themler theme download: \themes\[YOURTHEME]\templates\page
2. The "Post" template you designed in Themler actually results in a .tpl file called page--node--article--**XX**.tpl.php (in my case XX was the number 6, but this might be different in your case.) Copy this file.
3. In the Drupal backend, check the machine name of your content type that you want to be using the design you created in Themler for the "Post" template. You can do this by navigating to /admin/structure/types and clicking "edit" for the content type in question and inspecting the machine name.
4. Now rename the file you copied in step 2 to match: page--node--[YOURCONTENTTYPEMACHINENAME].tpl.php
5. Upload your new tpl file to the same directory on your server.
6. Clear the caches in your Drupal site
7. Repeat these steps (of Part 2) for each custom content type you have in your Drupal site.
8. Dance!
Note that these steps need to probably be repeated each time your export your theme so you may want to really spend some good amount of consideration and time designing the layout of your "Post" template so that you don't have to alter it often. Minimize the use of any shared elements with other templates so it doesn't inherit changes you make to other templates as much. That way you can just keep a copy of your custom .tpl files and drop those in each new theme export and keep the code snippet from part 1 handy and paste it into your theme-methods.php each time you download a new version of your theme.
In the meantime, I'd like to suggest to the Themler team to make the "post" template apply to all content types, or introduce a new template type to act as a universal template for content types. The current "default" template applies only to pages that are not content/ nodes. So all content in the form of custom created content types basically are un-styled and have no layout and are outside of the Themler user's control. Once again, there's custom content types in pretty much every Drupal site. Modules (think: drupal commerce) also add content types and off course popular Drupal distributions (Commerce Kickstart, Spark, etc) all ship with their own content types, and right now Themler is basically incompatible with all of them.