At the moment advanced_forum_extravars collects information from a number of hardcoded modules. When this function would invoke a hook (eg hook_advanced_forum_extra_vars) modules that you don't know about can support advanced forum. It also makes it easy to implement advanced forum support in custom modules without resorting to changing the theme.

Comments

neclimdul’s picture

StatusFileSize
new148 bytes
new27.16 KB

I came across a similar problem of extending advanced forum for a site. Also, the code base is alpha and quickly changing so its hard to commit too. So, I got some coffee and started hacking along the same lines with the hook.

What I quickly realized was that we where just adding additional preprocessors along the same lines as MODULE_preprocess_hook work in Drupal 6. So... I ended up ripping code out of the theme registry and the views module include system and ended up with the following patch.

Did I mention there was a lot of coffee involved? Also... it was 3am. Please give it a close eye but I think its a pretty cool solution to the problem that allows for a lot of code reuse in Drupal 6 as well as allowing for optimizations in that environment(use of the native theme registry).

I couldn't figure out how to create a directory for files in a patch so there is a zip with some includes.

neclimdul’s picture

StatusFileSize
new1.53 KB

the real modules directory.

neclimdul’s picture

Assigned: Unassigned » neclimdul
Status: Active » Needs review
StatusFileSize
new9.55 KB

Ok, sorry, here's a real patch that's review worthy. Not much has changed but there are no whitespace cleanups, extra docs, etc.

A run down of how this actually works.

Part 1) Internal calling, I think theme_forum_user is an easy example and the only place really taking advantage of this functionality. At the begining of this theme function we where manually calling the preprocessor function directly.

  template_preprocess_forum_user($variables);

Instead, we now call this:

  advanced_forum_call_preprocess('forum_user', $variables);

This enters the the code in the preprocessor.inc that very much emulates the theme registry in Drupal 6. So following our example, if we have privatemsg installed it looks for privatemsg_preprocess_forum_user. If I have a module name foobar it we be looking for foobar_preprocess_forum_user. This list is built for each function we call advanced_forum_call_preprocess and then the list is pushed into cache.

Then the functions are called and they add their variables are all merged together.

Part 2) Pluginness. So, how does privatemsg_preprocess_forum_user get added in. Well this is handled in advanced_forum_include. The code is stolen from views and interates through our modules and includes files from certain locations. Views uses this mymodule.views.inc and I've got it setup for advanced forums to use mymodule.forums.inc at the moment but this could be easily changed.

neclimdul’s picture

StatusFileSize
new1.76 KB
new13.81 KB

Finally got around to updating this.

Run down of changes:

  • This patch has better caching.
    • the file include search is cache
    • the preprocessor cache is keyed on the theme now which should be better
  • The preprocessor include is gone in favor of just using the d6_compat include
  • Much better documentation of functions
neclimdul’s picture

removed "is drupal 5" check from d6_compat file and merged with recent commit.

neclimdul’s picture

StatusFileSize
new13.57 KB

patch...

neclimdul’s picture

whitespace cleanup caused us to go out of sync.

rerolled.

neclimdul’s picture

I think the patch got lost in a server hiccup or something. repost.

neclimdul’s picture

trying again

michelle’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

Comitted to 5.x. Need to port to 6.x.

Michelle

michelle’s picture

StatusFileSize
new33.42 KB

I got part way thru porting this a week ago and haven't had time to deal with it since. Here's what I did so far.

Michelle

neclimdul’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Finally got around to getting this updated. The only difference between this and michelle's posted code is the cache functions have been updated to the drupal 6 api and the advanced_forum_load_preprocessors function call has been moved earlier in the drupal initialization process to the registry builder will pickup the functions in the includes.

You can see my changes in the second attached patch.

neclimdul’s picture

dang upload problems! trying again...

michelle’s picture

Title: Collect extra vars by a hook implementation » Adapt style plugin system to cover code plugins
Assigned: neclimdul » Unassigned
Category: feature » task
Status: Patch (to be ported) » Active

Might as well continue using this issue. We've decided to use the new plugin system for the styles to handle this as well rather than port the patch.

Michelle

neclimdul’s picture

Title: Adapt style plugin system to cover code plugins » Collect extra vars by a hook implementation
Assigned: Unassigned » neclimdul
StatusFileSize
new3.8 KB

Finally an updated patch for 6.

And I'm claiming my issue back.

michelle’s picture

Status: Active » Fixed

Committed, yay!

Thanks!

Michelle

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.