Posts Topics Forums Images
Search videos from message boards Videos Search messages from microblogs Microblogs Search messages from imdb.com Imdb Search messages from yuku.com Yuku Search messages from lefora.com (free forums) Lefora
My account: Login | Sign Up
Loading... 

Thread: how to share theme variables with module?

Started 1 month, 2 weeks ago by bjillygates
Hello, Have written some module. Want to have access from this module to $variables variable generated for each instance of page.tpl.php . What is the correct way to do this? Tried to using '$global $variables' declaration in mymodule.module , but it does not work -- no effect. Tried to pass $variables from theme_preprocess(&$variables) function using $_SESSION: part is ...
Site: Forums | drupal.org  Forums | drupal.org - site profile
Forum: Module development  Module development - forum profile
Total authors: 3 authors
Total thread posts: 8 posts
Thread activity: no new posts during last week
Domain info for: drupal.org

Other posts in this thread:

nevets replied 1 month, 2 weeks ago
If you are writing a module you want to implement modulename _preprocess_page(), see Setting up variables for use in a template (preprocess functions)

bjillygates replied 1 month, 2 weeks ago
Thanks for the reply but it does not help at all: what I am doing wrong? I get stuck. mymodule.module : <?php function mymodule_preprocess_page (& $variables ) { $_GLOBALS [ 'p_links' ] = $variables [ 'primary_links' ]; // primary_links definitely exists -- checked out with 'echo' } function somefunc (...) { ... drupal_eval ( file_get_...

nevets replied 1 month, 2 weeks ago
Its not clear what you are trying to do, hook_preprocess_page() is for setting variables used by page.tpl.php. You in fact seem to be replicating the theme system with somefunc().

marcvangend replied 1 month, 2 weeks ago
It looks as if you're trying to use the theme system in reverse, but I'm afraid that's not going to work. Drupal calls module hooks first and does the page theming afterwards. I don't know when you're calling somefunc(), but probably, the page theming has not started at that point, so mymodule_preprocess_page() is not yet executed. Also, you can't just run file_get_contents(FILENAME) and expect...

bjillygates replied 1 month, 2 weeks ago
2) you're creating a new page, block or other element that you want to appear in your site (in other words you're writing a module) Yes, I am creating a module which defines new blocks. You can however figure out where $variables['primary_links'] gets its contents and do the same in your own code. Thanks for the pointer! I have managed to done what I want; Now it looks like...

bjillygates replied 1 month, 2 weeks ago
Thanks for All for the Help! Question is closed.

marcvangend replied 1 month, 2 weeks ago
I'm glad that it works for you, but it still looks as if you're trying to re-create the theme system. The "Drupal way" to do things like this is to implement hook_theme: see http://drupal.org/node/165706 and http://api.drupal.org/api/function/hook_theme/6 (check out the comments as well). When you use the Drupal theme system as intended, the following will happen: 0. you have already ...

 

Top contributing authors

Name
Posts
bjillygates
4
user's latest post:
how to share theme variables...
Published (2009-11-08 09:06:00)
Thanks for All for the Help! Question is closed.
nevets
2
user's latest post:
how to share theme variables...
Published (2009-11-07 21:30:00)
Its not clear what you are trying to do, hook_preprocess_page() is for setting variables used by page.tpl.php. You in fact seem to be replicating the theme system with somefunc().
marcvangend
2
user's latest post:
how to share theme variables...
Published (2009-11-08 11:16:00)
I'm glad that it works for you, but it still looks as if you're trying to re-create the theme system. The "Drupal way" to do things like this is to implement hook_theme: see http://drupal.org/node/165706 and http://api.drupal.org/api/function/hook_theme/6 (check out the comments as well). When you use the Drupal theme system as intended, the following will happen: 0. you have already implemented hook_theme...

Related threads on "Forums | drupal.org":

Related threads on other sites:

Thread profile page for "how to share theme variables with module?" on http://drupal.org. This report page is a snippet summary view from a single thread "how to share theme variables with module?", located on the Message Board at http://drupal.org. This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity