vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Applying Stylesheet to IFRAME contents (https://vborg.vbsupport.ru/showthread.php?t=91261)

m0nde 06-28-2005 04:57 PM

Applying Stylesheet to IFRAME contents
 
I'm using vbadvanced and have created a module to show information in an IFRAME.
However, the contents of the IFRAME is never formatted according to what I've set up in my style. The contents always has a white background with black text in Times New Roman.

Is there something I'm missing?
I've tried to include a class="alt1" in the IFRAME tag and have even surrounded the contents of the HTML file in <span class="alt1"> tags, all to no avail.

Included is an example:

HTML Code:

<td class="$getbgrow alt1" width="100%" align="center">
<iframe title="Text" name="I1" width="100%" height="100" src="/forums/modules/text.html" marginwidth="1" marginheight="1" scrolling="auto" border="0" frameborder="0">
<!-- Alternate content for non-supporting browsers -->
<a href="/forums/modules/text.html" target="_blank">Text</a>
</iframe></td>

The text.html file is a very long page and that is why I want it included in an IFRAME with a scroll bar.

HTML Code:

<span class="alt1"><strong>Blah blah blah ...</strong><br /><br />Blah blah blah</span>
- Sid

tamarian 06-28-2005 05:21 PM

I think the iframe page needs access to the style sheet on it's own, since it's loaded separately. That's just a guess :) To test this guess, save a copy of your stylesheet to a file, and add the file to the iframe page...

m0nde 06-28-2005 11:26 PM

Quote:

Originally Posted by tamarin
I think the iframe page needs access to the style sheet on it's own, since it's loaded separately.

Sorry for being daft, but how do I do this? I understand that it needs access to the .CSS information but I have several themes on my vbulletin site, so how will I get this to work?

- Sid

tamarian 06-28-2005 11:37 PM

Quote:

Originally Posted by m0nde
Sorry for being daft, but how do I do this? I understand that it needs access to the .CSS information but I have several themes on my vbulletin site, so how will I get this to work?

- Sid

Ah, I didn't consider multiple styles. One possible solution is to make the iframe file a PHP file. This way you can include global.php which should give you access to the user's style.

deathemperor 06-29-2005 01:24 AM

that iframe is simply a page, so you need to use $headinclude to get the CSS properly.

m0nde 06-29-2005 07:55 PM

Quote:

Originally Posted by deathemperor
that iframe is simply a page, so you need to use $headinclude to get the CSS properly.

I have no idea how to use $headinclude :( Please spell it out for me.

Quote:

Originally Posted by tamarin
One possible solution is to make the iframe file a PHP file. This way you can include global.php which should give you access to the user's style.

I did the following and named it text.php and it just got me a blank IFRAME :ermm: :
PHP Code:

<?php

require_once('/forums/global.php');

?>
<span class="alt1"><strong>Blah...etc.</strong><br /><br />More blah</span>

Can you tell me what I should do to remedy this?

- Sid

nug 06-30-2005 02:28 AM

I'm trying to do the same thing. Solved the problem by putting $style[css] in the <head> tags.

m0nde 06-30-2005 11:22 AM

Quote:

Originally Posted by nug
I'm trying to do the same thing. Solved the problem by putting $style[css] in the <head> tags.

When I put $style[css] in the <head> tags of the IFRAME'D html file, I get the words $style[css] showing up as text in the IFRAME.

tamarian 06-30-2005 11:42 AM

Put it this way:

<? echo $style['css']; ?>

m0nde 06-30-2005 12:56 PM

Quote:

Originally Posted by tamarian
Put it this way:

<? echo $style['css']; ?>

Thankyou for spelling this out. I'm a total PHP newbie as you can tell! :speechless:

Now, I've done what you've said and this is the code I've got:

HTML Code:

<html>
<head>
<? echo $style['css']; ?>
</head>
<body>
<span class="alt1"><strong>Blah...</strong><br /><br />Blah Blah</span>
</body>
</html>

I've named this text.html and I'm calling this using an IFRAME.
But when I do this, I just get a white background with black text and no formatting other than the bold and line breaks in the scrolling IFRAME.

Can someone tell me what I'm doing wrong?

- Sid

tamarian 06-30-2005 01:51 PM

Quote:

Originally Posted by m0nde
HTML Code:

<html>
<head>
<? echo $style['css']; ?>
</head>
<body>
<span class="alt1"><strong>Blah...</strong><br /><br />Blah Blah</span>
</body>
</html>


You're missing global.php. Try this:
HTML Code:

<? require_once('global.php'); ?>
<html>
<head>
<? echo $style['css']; ?>
</head>
<body>
<span class="alt1"><strong>Blah...</strong><br /><br />Blah Blah</span>
</body>
</html>

Which may produce some warning, but let's see if it works.

m0nde 06-30-2005 02:20 PM

Actually, no warning occurs and no changes either :(
It still shows a white background with black text.

- Sid

tamarian 06-30-2005 02:34 PM

We may have missed something very simple. alt1 and alt2 do not apply to <span>, I don't think.

You can test by accessing ther iframe page directly from the browser, and view the source, to see if the style is there as expected.

m0nde 06-30-2005 02:54 PM

Quote:

Originally Posted by tamarian
We may have missed something very simple. alt1 and alt2 do not apply to <span>, I don't think.

You can test by accessing ther iframe page directly from the browser, and view the source, to see if the style is there as expected.

If I access this page directly it still shows up as black Times New Roman (browser default font) text with a white background.

Even if the alt1 and alt2 aren't working properly, shouldn't the colour work? ...and the font?

I know that people have used IFRAMEs to display things like the shoutbox, etc.

- Sid

tamarian 06-30-2005 02:59 PM

I'm not sure because I don't have the files.

But what happens when you view the page source? What style is defined there?

m0nde 06-30-2005 03:07 PM

The source, when viewing the file directly in a web browser doesn't expand the PHP script at all!
It just shows the literal text. Why is this?

- Sid

tamarian 06-30-2005 03:43 PM

Quote:

Originally Posted by m0nde
The source, when viewing the file directly in a web browser doesn't expand the PHP script at all!
It just shows the literal text. Why is this?

- Sid

That's how it should work. You're all set.

m0nde 06-30-2005 10:53 PM

Quote:

Originally Posted by tamarian
That's how it should work. You're all set.

You're telling me the source, when viewed in a web browser is supposed to show up like:
HTML Code:

<? require_once('/forums/global.php'); ?>
<html>
<head>
<? echo $style['css']; ?>
</head>
<body>
<span class="alt1"><strong>Blah</strong><br /><br />Blah Blah</span>
</body>
</html>

I thought that the require_once was supposed to actually include all of global.php in that space and that the command to echo the style variable was supposed to type out the contents of that variable in that space.

tamarian 06-30-2005 10:58 PM

No, I thought you said it showed the lirterals. I took that to mean the actual colour codes for alt1 and alt2.

The page view you showed tells me that you have not made the file a .php as I suggested earlier. To interpret it as PHP, it needs to be a PHP extension. :)

m0nde 06-30-2005 11:35 PM

Quote:

Originally Posted by tamarian
To interpret it as PHP, it needs to be a PHP extension. :)

Thanks. I have tried this both with an HTML extension and a PHP extension. When I try it with a PHP extension, it just shows up as blank with a white background. You've seen above what happens when I try it with an HTML extension.

The source of the PHP file if viewed after being parsed shows up as follows:

PHP Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<
HTML><HEAD>
<
META http-equiv=Content-Type content="text/html; charset=iso-8859-1"></HEAD>
<
BODY></BODY></HTML

It seems that the global.php is the problem because if that is excluded the rest of the file shows something. I know that global.php resides in that place (/forums/global.php) and I've tried replacing the whole thing with:
PHP Code:

<? phpinfo(); ?>

to test whether anything's going on and this does show the information page in the IFRAME.

- Sid

deathemperor 07-01-2005 01:15 AM

the page must be save as .php page, .html page won't work.

m0nde 07-01-2005 01:33 AM

Quote:

Originally Posted by deathemperor
the page must be save as .php page, .html page won't work.

I have saved the page as a .php page. The file being called for the IFRAME is text.php and has the following inside it:
PHP Code:

<? require_once('/forums/global.php'); ?>
<html>
<head>
<? echo $style['css']; ?>
</head>
<body>
<span class="alt1"><strong>Blah</strong><br /><br />Blah Blah</span>
</body>
</html>

When I view this text.php in the browser, not trying to view it in the IFRAME, to test it, I get a blank page. I then view the source and get:
PHP Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
<
HTML><HEAD
<
META http-equiv=Content-Type content="text/html; charset=iso-8859-1"></HEAD
<
BODY></BODY></HTML

If I just put
PHP Code:

<? phpinfo(); ?>

into my text.php file, to see if anything works at all, I see the php information whether I view it in my IFRAME or if I just view it normally. What is happening with the call to the global.php? Am I doing this wrong?

- Sid

tamarian 07-01-2005 01:54 AM

Sid, this may be a problem of not including global.php You are including it, but the path may be wrong, as it will depend on where your test.php file exist. Try running it in your main forum home first, and remove that '/forum/' directory from the path.

m0nde 07-01-2005 02:06 AM

Quote:

Originally Posted by tamarian
Sid, this may be a problem of not including global.php You are including it, but the path may be wrong, as it will depend on where your test.php file exist. Try running it in your main forum home first, and remove that '/forum/' directory from the path.

Yes, this is what I think is happening. I do know that global.php exists in my /forums directory because if I try http://www.bostonlove.org/forums/global.php it comes up and says
Code:

Critical Error
global.php must not be called directly.

This is very odd. I will try to run it in the same directory as global.php without any path in that line and see what happens.

- Sid

If I move it into the same folder as global.php it suddenly works!

I think I'll just leave it there! Thank you very much for your help.

But, for future reference, can you explain to me why this is happening?

Should I change that line to a relative path?
[php]<? require_once('../global.php'); ?>- Sid

deathemperor 07-01-2005 07:52 AM

Quote:

Originally Posted by m0nde
Should I change that line to a relative path?

both work fine if you use the correct path

m0nde 07-02-2005 07:52 PM

Quote:

Originally Posted by deathemperor
both work fine if you use the correct path

This is inside a module on my vBadvanced CMPS front page. Do you think that this is somehow changing the path?

- Sid


All times are GMT. The time now is 09:56 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02027 seconds
  • Memory Usage 1,821KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (6)bbcode_html_printable
  • (6)bbcode_php_printable
  • (15)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (26)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete