Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Accessing a template global from a plugin

Quote Reply
Accessing a template global from a plugin
I am wondering if there is a way to access the value of a global (of the current template in use) from a plugin?

thanks,
Knut Reistad
Gjerrigknark.com
Quote Reply
Re: [KA] Accessing a template global from a plugin In reply to
Depends on what you are trying to do, and how you are trying to do it.

If the plugin is called from inside the template, you can call the the tags using the current tag format (see the 3.0 beta announcement)

If you are not calling the plugin from inside the template, the globals would all be undefined, and by definition, not available.

You can load the values that *would* be in the template globals by calling the correct functions from within links that would have loaded those variables to begin with.

What globals are you trying to access?


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Accessing a template global from a plugin In reply to
Ahh, I see.

What I am trying to do is to modify what links are shown (all results in generate_category, generate_cool, generate_new, search_results and so on), by applying a pre hook that adds an extra condtion to the query that selects which links to show.

This condition I want to be template specific. Furter I thought adding a template global called "condition" would be a nice place to store this template specific value. The problem is that I have no idea how to access the value of the template global from inside the pre hooked plugin (or if it is possible).

I suppose this qualifies for the case you mention where the plugin is is not called from inside the template, so I really would like to know how to load the template global value from inside links.

Thank you very much for your help so far!

Knut Reistad
Gjerrigknark.com
Quote Reply
Re: [KA] Accessing a template global from a plugin In reply to
Hi,

What you are trying to do doesn't sound straightforward - i.e. I'm not sure that it will be easy to add in an extra condition. However, the global bit is easy - you can just add another sub in the plugin pm file and call that from within the plugin.