Preprocess suggestions in Drupal 7 without Devel Theme Developer module - drupal

Is there any alternative way to get preprocess/process suggestions without using Devel themer (Theme developer) module?
Apparently I can use $conf['theme_debug'] = TRUE; to get template suggestions, and dpm or var_dump to list available vars, but I can't seem to find a way to list preprocess/process function suggestions like devel themer does

You can use only devel module, not devel_themer
Once installed go to /devel/elements
It will show you a list of all site themes, you can preprocess/process all this elements

Related

Change theme for node add page in Drupal 7

I tried using hook_custom_theme to change the theme for the node add page for a specific content type, like this, without success:
function mymodule_custom_theme() {
if (current_path() == 'node/add/mytype')
return 'anothertheme';
}
I know the function is running, and I know the comparison is returning TRUE. Why is it not working?
I think you are not writing the theme name correctly.
But there is a module which could do this work for you: https://drupal.org/project/themekey
Regards.
1) Do you use the correct machine name for the theme?
2) Are you sure that there are not other modules to override this later?
3) Is the page cached? If so this may not work properly.
Same question and discussion here: https://drupal.stackexchange.com/questions/812/how-do-i-change-a-theme-based-on-the-url
Useful modules:Page Theme, Context, ThemeKey.

Drupal Module for Zoom Print and Save

i would like to ask about module on Drupal. I need to add "Zoom", "Print", and "Save" functionalities. I am sure there must be a module to handle this. Is there any solution about which module I should use? For information, i am using Drupal 7 and need to add the functionalities to Views page. Thanks
You can use this module for printing: http://drupal.org/project/print
This also gives provision to save as pdf & email the article.

drupal_find_theme_functions called on every page - is our theme registry being rebuilt?

Our new D7 site was running very slowly so I did some profiling with devel/xhprof and found that D7 was doing millions of preg_grep function calls within drupal_find_theme_functions() in theme.inc. This happened on every page load.
It's my understanding that the drupal_find_theme_functions function should only be called when the theme registry is being rebuilt - am I correct in that?
I made sure that "rebuild theme registry" was off in devel, and then disabled devel entirely. However, I'm still seeing those millions of function calls to preg_grep in drupal_find_theme_functions on every page load (I added a piece of code to theme.inc to log when the function was called).
We're using a theme based on Omega and if we are rebuilding the theme registry each time I'm not seeing how/why it's happening. We're turning off as many contrib modules as we can in the meantime. Any help/advice would be MUCH appreciated!!
Also check your theme settings and template.php, maybe theme rebuiding trigger there.
For example Zen theme has option ->
"Rebuild theme registry on every page"
I don't familiar with Omega, but check any way

please let me know what the following lines of code mean

What is mean by the following code, I found it in the comment module (drupal 6)
return theme('box', $title, drupal_get_form('comment_form', $edit, $title));
I have used this theme function before, but I had defined some themes under hook_theme(). but I didn't see any themes defined as 'box', also I found same theme 'table'
Could you please show some urls where it explains about these things
Thank you very much
With the Drupal theme system you can overwrite theme functions. So if you don't like the markup that theme_box makes, you can make my_theme_box instead and Drupal will use that function instead. The thing is in order for this to work you can't call theme_box directly. If you do that you in your module your theme can't alter the output. Instead you call theme('box', ...) this will tell Drupal that's it's the box theming function you want. It will the find out which function to call based on what's available. So if your theme doesn't have my_theme_box defined theme_box will be used instead.
Have you already read Drupal API Reference? There's an explanation about themes, too.

How does one inject variables into page templates from a custom Drupal module?

We've created a custom module for organizing and publishing our newsletter content.
The issue I'm running into now -- and I'm new to theming and Drupal module development, so it could just be a knowledge issue as opposed to a Drupal issue -- is how to get each newsletter themed.
At this point the URL structure of our newsletter will be:
/newsletters/{newsletter-name}/{edition-name}/{issue-date} which means that we can create template files in our theme using filenames like page-newsletters-{newsletter-name}-{edition-name}.tpl.php, which is great. The one issue I'm running into is that all of the content comes through in the $content variable of the theme. I'd like to have it come through as different variables (so that I can, inside the theme, place certain content in certain areas.)
Is there a proper way for doing this?
Edit: To answer some questions: The issue is a node (there are issue, edition and newsletter nodes) and the path is being set using hook_menu with wildcards and a router.
The best answer I could find was to add a check inside of phptemplate_preprocess_page to send the vars back to the module and have them be updated.
Like so:
function phptemplate_preprocess_page(&$vars) {
if (module_exists('test_module')) {
_test_module_injector($vars);
}
}
then in my test_module.module file I created this function:
function _test_module_injector(&$vars) {
$vars[] = call_to_other_functions_to_load_vars();
}
It seemed to work. I wish there was a way to do this without having to touch the theme's template.php file, but otherwise this works well.
If there were better documentation for template preprocess functions, Drupal would be a lot more accessible - as it is, you need to piece together the information from a lot of different explanations. One place to start is here:
http://drupal.org/node/223430
but if you take the time to work through the tutorial below, you'll find you can do most things:
http://11heavens.com/theming-the-contact-form-in-Drupal-6
This is an old post, and the OP's issues seems to have been solved.
However, just for others finding this through Google (or otherwise):
Install the 'Devel' module: http://drupal.org/project/devel
Also the 'Devel Themer' module: http://drupal.org/project/devel_themer
Use Devel Themer to go through the $content variable and find what you need to pull out.
There are a bunch of Devel/Themer docs/tuts out there, but its usage is pretty straightforward. Note, though, that some stuff in there will need to be sanitized before printing in the theme.
The suggestion to show the node as a View and then modifying the view templates sounds pretty crazy, though it'll work.

Resources