How to change site_name and site_slogan vars within the script/module?

petiar - May 1, 2008 - 10:01

Hi everybody,

I am developing new module which should allow users to set up their own title and slogan for their blogs. What I don't know is how could I change the site_name and site_slogan variables inside my module without need to hack the page.tpl.php. I assume this will have something to do with the template preprocess but I am not very experienced with this yet. Can anyone think of any solution?

Thanks a lot,
Petiar.

variable

kuldip - Gloscon - May 1, 2008 - 10:32

You can temporary set value of the following variable when someone visit particular blog (i dont know how you manage it , you can manage it through url or session)

variable_set('site_name', "YOUR BLOG NAME");
variable_set('site_slogan', "YOUR SLOGAN");

--
Kuldip Gohil
Software Engineer - Global Software Consulting (Gloscon)
1-888-DRUPAL-9 (378-7259)
http://www.gloscon.com

How do you mean 'temporary'?

petiar - May 1, 2008 - 10:51

I am afraid variable_set function updates persistent variables and updates db, so if I use this command I'll actually overwrite settings for whole website that means users browsing other than blog pages will see these variables changed as well. Or am I missing anything? Anyway, thanks for reply!

--
Petiar
The biggest slovak folk music magazine proudly uses Drupal
http://folk.sk

Solution?

petiar - May 2, 2008 - 09:10

I've found out that site_name is being kept in $GLOBALS['conf']['site_name'] and as such can be easily overwritten. However, it looks like bit dodgy way of coding - overwriting global vars.

Does anyone has got any other idea?

Thanks.

--
Petiar
The biggest slovak folk music magazine proudly uses Drupal
http://folk.sk

I have a similar need, and

tgcondor - August 25, 2008 - 04:43

I have a similar need, and thanks for pointing out GLOBALS. If you find a better way, though, please post here.

TAA

 
 

Drupal is a registered trademark of Dries Buytaert.