So, I am developing a custom module for a client, may submit it when I am done, it's got cool possibilities, but, I need to know one thing to take it to the next level...I need to get the value of $head_title into the module, and morph it for other purposes...the other purposes I have all done already with other values, but I really want the $head_title to work with.

How can I grab that value within the context of a simple D7 module?

Thanks for any help.

Comments

WorldFallz’s picture

In what context is the module operating?

In general, you can see what variables are available to your code with get_defined_vars(). If it doesn't appear there, it's likely your module will need to implement _preprocess_html to manipulate it.

goofus’s picture

Hello,
Here are 2 techniques I use during development.

First I try to specify my requirements. I try to eliminate any ambiguities in my descriptions. For example, you refer to a php var "$head_title" , but you have not posted the context. Therefore, I'm not sure what "$head_title" means.

Next. I refer to documentation. Drupal's API documentation is located here: http://api.drupal.org/api/drupal. I used the search box and typed in "title". I got several results that may be useful to you. Thus, perhaps you should check out the API page and search on "title".

Please note, if that solves your issue, please edit your original post's title and add "[SOLVED]" to either the beginning or the end. That way other folks can find the solution.

Good Luck :)

dbmasters’s picture

Fair points, I guess I didn't realize there was more than one "head_title"...what I want, is whatever the content of the theme's tags is, I want to pull into the module I am developing. As far as what context I want to pull it in...I guess in whatever context I have to, or whichever is best...right now my module is very simply, very simply, so I am open to any tactic that will work.

I have read through documentation, google searched read a lot but can't find anything that addresses it directly...if I am missing something, I'd love to see the doc...I have limited module development experience and am trying to learn as much as I can, so I am all ears.

I will try some hints left above and see, so thanks for those.

jaypan’s picture

I can't speak for others, but I myself still have no clue what exactly you are asking.

Contact me to contract me for D7 -> D10/11 migrations.

dbmasters’s picture

In the variables for themes there is a variable called "$head_title", this holds the content that goes into the tag of each pages...I want the content of that variable accessible in a module I am building and I can't figure out how to pass it in there, that's all.

get_defined_vars() shows nothing...I'll look into the aforementioned preprocess function...never worked with one of those yet.

WorldFallz’s picture

The variables available to the theme are context sensitive. They're not always the same in every template and function. afaik, $head_title is only made explicitly available to the html template and process and preprocess functions.

jaypan’s picture

You can get the current page title with drupal_get_title()

Contact me to contract me for D7 -> D10/11 migrations.