Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.0k views
in Q2A Core by
I want to use myq2a through an iframe, what seems to work very well. But my iframe is limited in space, so I would need a second css file where the width is reduced. I can write such a css file but I dont know how to tell q2a that it is loaded in an iframe ?

Somebody knows about that ? Should be possible (I believe).

Thanks You so far

monk333

1 Answer

+1 vote
by
 
Best answer
You can change the name of the CSS file used by overriding the css_name(...) function in your theme class.

As for knowing whether it's in an iframe or not, the simplest way would be to use a different subdomain which hosts the same site, then have your theme check the $_SERVER['HTTP_HOST'] with your css_name(...) function.
by
edited by
Just to understand it well, I would make an install with the same config on a subdomain or subdirectory !?. This wouldnt cause any problems regarding the database ?

There I could just use another stylesheet and use this second install to show up in the third sites iframe.

This would resolve any problem.

Thank You so far

monk
by
It's even simpler. You would have only one install, and have the subdomain point to the same server directory as the main domain. The server would still be able to know which domain was used via $_SERVER['HTTP_HOST'].

You also do have the option of using two installs with the same database details in the config file, but this would be a more complicated solution.
by
edited by
EDIT: I am a bit slow now, I will try it out and see how close I get.
by
Thank You, works perfectly. I included q2a in an (very simple) facebook app and used for the iframe this second css file through the subdomain hint, what is VERY elegant. Besides it allows me to include facebook specific functions just by checking the host name...

Now comes the difficult part, logging in the facebook users.... I try to avoid a real single login, as it is inside facebook, and I could make use of the ID, name and more...but I am quite sure that later Iwill ask a related question..

Thanks again, for this excellent q2a "playground", it is real fun for me....without being an programmer...
by
edited by
I changed the name of my stylesheet in the css_name(...) function and now only the default template loads regardless of the admin setting!.

UPDATE:

qa-include\qa-app-format.php

commented out lines: 1222 and 1223

        if (!file_exists(QA_THEME_DIR.$theme.'/qa-styles.css'))
            $theme='Default';

so that I can change the name of the style sheet in my theme without the script loading the default theme as a result of not detecting qa-styles.css
...