I'm writing a module that works in conjunction with a plugin to create a contextual background for a website.
The premise is this: if the user is on the home page, the background image is whatever is specified as the default in the plugin parameters.
If the user is on a categories list page, the background image is whatever is specified as the default in the (custom) component parameters.
If the user is on an articles list page, the background image is whatever is specified as the default in the (custom) category parameters.
If the user is on an article page, the background image is whatever is specified as the default in the (custom) article parameters.
To make this even more fun, I've written my own components that display profiles instead of articles. They work in exactly the same way, but may not contain all of the coding that the Content component does. My reasons for writing custom components are beyond the scope of this question.
The plugin creates and adds the basic markup to the page, and this works fine throughout the site. The home page works exactly as I require.
The module is supposed to add the stylesheet et al. to the header of the document, which it does fine. The problem is that the module is supposed to first ascertain the context, then load the parameters from the given context. HERE'S MY PROBLEM: I can't find the code to ascertain the context and read the parameter as per the rules above.
I tried it as just a plugin (without the assistance of the module), but as a content plugin it didn't work on the home page, and as system plugin it didn't have access to content parameters. I also considered having two plugins working together, but this seems bad practice. Perhaps a new plugin that is neither content nor system, but has access to both contexts?
ADDITIONAL INFO:
I've written a number of components that represent different groups of entities. Each component has its own distinct parameters, but also some common ones among all of the components. Each component has the functionality to be 'instantiated' in the same manner as the core Joomla 'banner' and 'contact' components. An example of a common parameter is the 'gallery' parameter; every one of the components has a 'gallery' parameter, and each 'instance' has the option to have its own value. The 'gallery' parameter contains a folder URL for a folder containing images that relate to the specific component instance.
An example of how this is all supposed to pull together:
I have a component called 'driver' that will act as the container for - you guessed it - drivers. In the components admin menu, I can add drivers, specifying their name, age, etc. and I can include a mugshot and gallery URL for the driver.
When a user on the site side loads a driver page, I want the code to load in all of the images from the gallery folder, and those to rotate in the background. I want to be able to add/remove/replace images at any time without having to refer to the options page for the driver. Just to make it even more complicated, as each background image loads, EXIF meta data is read from the image, and this is displayed, with a thumbnail, in the foreground at the bottom of the page.
Now, this all works perfectly in the root of the site, and for the most part works throughout. The part that falls down is the retrieving - by the module - of the variable from the driver 'instance'. Sure, I can write some tidy SQL and db calls, but surely there most be a way for a module to retrieve component, category and article params?