Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
2.1k views
in Q2A Core by
Hi Gidgreen,
I have prepared Orkut Application for my website :http://www.prepare4interview.com
Here is the url: http://www.orkut.co.in/Application.aspx?appId=549445333343

As my site is getting embedded with a iframe, i want to reduce the width of main section to make it fit. But i dont want to change current theme. So i would lik eot know, is it possible to set a theme by passing theme in parameter?

1 Answer

+1 vote
by
 
Best answer
Interesting question! Yes, you can do this with a small code modification. I see you're using version 1.2 beta, so look at qa-page.php (older versions should see qa-index.php). Where you have this line:

$themeclass=qa_load_theme_class(qa_get_option($qa_db, 'site_theme'), $qa_template, $qa_content, $qa_request);

Replace it with this:

$qa_theme=qa_get('qa_theme'); // get from URL parameter if possible
if (!isset($qa_theme)) // otherwise get option
    $qa_theme=qa_get_option($qa_db, 'site_theme');
$themeclass=qa_load_theme_class($qa_theme, $qa_template, $qa_content, $qa_request);

The other issue is that you will probably want the theme to be passed from one page to another, if the user navigates around. So to do this, you would modify qa_path(...) in qa-base.php, and add this at the start:

$qa_theme=qa_get('qa_theme');
if (isset($qa_theme))
    @$params['qa_theme']=$qa_theme;

This won't work for Ajax voting, but that won't matter if both themes use the same layout for the voting boxes. There might also be some other places where it doesn't work right, so please try it out and report back!
by
Awesome, I didn't expect this can be achieved. Your software architecture is so flexible to fit with users like us...

I don't have words to say.. Really you are doing wonderful job!

Thank you very much.. I will implement this and update you!
by
Hi Gidgreen,
As per you suggestion, I have changed qa-page.php and qa-base.php files.

And gave the theme name in url like this "index.php?qa-theme=test"
where 'test' is the new theme created with minimum width.
But i could nt make it work.
Am i missing anything?

You said "you would modify qa_path(...) in qa-base.php"
May i know how to do this?
by
Please use qa_theme as the parameter (with an underscore), not qa-theme.
by
Yes you are right, Now i used qa_theme, works fine in first page. But when clicking any link, it goes back to original theme.

Could you please help me on this?
by
Did you add the code into qa-base.php that I suggested above?
by
yes, I have added after "<?php " in qa-base.php..
by
No, you need to add it at the start of function qa_path(...)
by
edited by
Ahh.. Sorry...
Works perfectly now...

One small thing is when i try to login.. goes back to old theme.
No problem, if you get some time, you please help me on this.. :)

Thanks a lot!

--
How to reduce answer textarea columns count from 40 to 20?
Due to its column property, not able to reduce its size to fit into main-area.
Please have a look, if time allows.. :)
by
I move it into production.. http://www.orkut.co.in/Application.aspx?appId=549445333343

Works perfectly..
Thanks a lot! :D
by
You can use a plugin to override the core function - instead of the core hack:
http://www.question2answer.org/qa/45225/how-to-load-another-theme-using-a-plugin
...