TinyPortal

General => Chit chat => Topic started by: fenris_w0lf on January 24, 2006, 09:57:02 PM

Title: Inject html file(s)
Post by: fenris_w0lf on January 24, 2006, 09:57:02 PM
Hi,

I did a search but couldnt find this documented/discussed anywhere, I appologize if I'm wrong.

Say you have html file(s) on your TP server that gets updated on a regulary basis. You want to present the content of this file when the user press some link in a block in the "sidebar" and the content gets displayed in the "Content Area" / "Body" of the "Home Page".

Possible ?
Title: Re: Inject html file(s)
Post by: Rasyr on January 24, 2006, 10:04:33 PM
 Read the following:

http://www.w3schools.com/tags/tag_iframe.asp

Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 24, 2006, 10:16:51 PM
First...MAN your fast :D
Second....oj!!!! that looks NEAT!!

Now;

The code is:


<iframe
src ="/default.asp"
width="100%">
</iframe>


Two questions:

1) Its possible to replace "default.asp" with "default.html" ? (sorry I dont know the difference betw asp and html :(( )
2) Where can iframes be used within the TP framework ?
Title: Re: Inject html file(s)
Post by: Xarcell on January 24, 2006, 10:20:53 PM
You can put just about anykind of file in a iframe. Anything that can be viewed by a browser anyways.
Title: Re: Inject html file(s)
Post by: Xarcell on January 24, 2006, 10:26:25 PM
Also, notice the attributes you can add. Say if you wanted to have no borders, then use:



<iframe border="0"
src ="/default.asp"
width="100%">
</iframe>



There are alot of atributes you can use for it. Even no scrolling. However, you can set a Iframe width attribute to 100%, you cannot set the hieght to 100%.

There are javascripts that allow it, but only if the page is in teh same domain as the iframe.


Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 24, 2006, 10:32:31 PM
Hey thanks Xarcell!!

Hmm...I seem to recall reading something about having to turn off some WYSIWYG editor to make this work - am I remembering correctly ? If so; where do I do this ??

And; does that mean I would also have to turn it off for regular posting ?

And; where would I find these javascripts that allows for height adjustments ? (My first two iframes will most likely be located on same domain)
Title: Re: Inject html file(s)
Post by: Xarcell on January 24, 2006, 10:35:48 PM
If your using v7 of TP, then yes. I recommend you turn it off. However, if your using v8 of TP, it should work fine.

Be sure to add the  height="###" attribute to your iframe.

If you need anymore help let me know.
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 24, 2006, 10:46:41 PM
Thanks again Xarcell!!

I'm using:
Powered by SMF 1.1 RC1.
Oxygen / TinyPortal v.0.75 by Bloc


Still a few unanswered questions:

* Where can iframes be used within the TP framework ?
* Will turning the WYSIWYG editor off, also affect regular posting in the forum - or just articles etc?
* You said:

QuoteHowever, you can set a Iframe width attribute to 100%, you cannot set the hieght to 100%. There are javascripts that allow it, but only if the page is in teh same domain as the iframe.

where would I find these javascripts that allows for height adjustments ?
Title: Re: Inject html file(s)
Post by: Xarcell on January 24, 2006, 11:00:43 PM
You can use iframes in the theme, articles, or blocks.

WYSIWYG editor only effects what you write for articles.

http://dynamicdrive.com/dynamicindex17/iframessi2.htm

Is the page your wanting to put in a article have links in it to other pages? If not, there is a better method than iframe.
Title: Re: Inject html file(s)
Post by: Xarcell on January 24, 2006, 11:03:12 PM
In an article using php, this may work:


<?php

include('the name of page.html');

?>
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 24, 2006, 11:14:28 PM
Thanks again Xarcell, really appreciate it!

One of the pages has MANY links in it, the other page has none. What is the other way of doing it ?
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 24, 2006, 11:33:37 PM
Hahaha this r0x !!!!

I just iframed this HUGE html file with tons of info (it did time out tho once) but when I refreshed it displayed it just nicely, and with the java-fix even nicer lol

THANKS !! :D

I'm still curious about that other way of doing it tho (when there's no links in the page thats gonna get iframed) - perhaps its possible in a block ?? (there's not much text in that file)
Title: Re: Inject html file(s)
Post by: Xarcell on January 24, 2006, 11:44:50 PM
That other way is better, only if the links open in a new window I think. I haven't tested it to see if clicking a link loads it in-itself.

You can always make one of each and see what happens.
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 25, 2006, 12:34:09 AM
Adding


<?php
include('myhtmlfilehere.html');
?>


to a phpbox block I get

Parse error: parse error, unexpected '<' in /home/evanss/public_html/Sources/Load.php(1598) : eval()'d code(32) : eval()'d code on line 1
Title: Re: Inject html file(s)
Post by: IchBin on January 25, 2006, 12:59:21 AM
You do not need the <?php or ?> in the phpbox. All you need is the include line.
Title: Re: Inject html file(s)
Post by: Xarcell on January 25, 2006, 02:22:15 AM
aaaaaahh, ya...

Silly me.
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 25, 2006, 12:03:27 PM
Hmm...that didnt work all that well. I just got the title of the block and no text below it.
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 25, 2006, 12:21:14 PM
And the weirdest thing....I have this html block where I have 3 links:

<a href="index.php?action=chat">Chat here!</a>
<a href="index.php?page=10">Chat statistics</a>
<a href="index.php?page=13">Who's online now?</a>


Where the two last is "iframe-phparticles". Page10 is using the java-script and iframe that Xarcell tipped me about, and it works SO beautifully! So I copy/pasted the code from this one into my text-editor, search/replaced the iframeid and pasted it into a new php-article. But for some odd reason I get:

Parse error: parse error, unexpected '<' in /home/evanss/public_html/Sources/Load.php(1598) : eval()'d code(76) : eval()'d code on line 1

???

Edit: typos
Title: Re: Inject html file(s)
Post by: feline on January 25, 2006, 01:40:32 PM
there is a singel ' in the line. this must masked ..

your code

<a href="index.php?page=13">Who's online now?</a>


change to

<a href="index.php?page=13">Who\'s online now?</a>


Fel
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 25, 2006, 02:01:56 PM
Hmm...then I got this:

(notice the the html-block is on right side: "Who\'s online now?")

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.federationofkings.com%2Ffiles%2Ftemp%2FImage7.jpg&hash=bc46bd851497e418e5d9dea6971ee45ab71f6bdf)


If I use the iframe or the php: include('myhtmlfilehere.html'); it gives this error, if I however change it to:

<a href="/files/irc/whosonafk.html">Who's online now?</a>

it works fine ???
Title: Re: Inject html file(s)
Post by: feline on January 25, 2006, 02:30:15 PM
Quote from: fenris_w0lf on January 25, 2006, 12:21:14 PM
<a href="index.php?action=chat">Chat here!</a>
<a href="index.php?page=10">Chat statistics</a>
<a href="index.php?page=13">Who's online now?</a>


is that in a php block?
by this .. you must that enclose in


echo ' ... your code ..
         ... more ..
       ';


and the links ..

in php normly is to use $scripturl
so like

global $scripturl;

echo '<a href="' . $scripturl . '?action=chat">';


Fel
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 25, 2006, 03:31:31 PM
Thanks Feline for the effort!!

The three lines is in a html block not php.
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 25, 2006, 06:58:41 PM
nah...I'm lost, could this be some sort of bug or something ?
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 25, 2006, 09:19:10 PM
iframes arent really accepted as a php article now is it ? :(

well...atleast I learned something...

:D

...weird it works for one article, but not the next..the articles were identical except - as mentioned - the iframe id ???
Title: Re: Inject html file(s)
Post by: eldacar on January 26, 2006, 02:40:15 AM
The simplest way would be to do something like echo file_get_contents(url);

You can do that for any file anywhere.
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 26, 2006, 07:52:54 AM
Thanks for that tip eldacar :)

edit: The parse error problem I was partly using non-php code in php articles and partly due to not removing the "<?php" and "?>"

*blush*
Title: Re: Inject html file(s)
Post by: AmphetaMarinE on January 28, 2006, 12:42:04 PM
Try this inside a php block fenris_wolf
echo '<a href="index.php?action=chat">Chat here!</a><br />
<a href="index.php?page=10">Chat statistics</a><br />
<a href="index.php?page=13">Who\'s online now?</a>';
Title: Re: Inject html file(s)
Post by: fenris_w0lf on January 28, 2006, 06:56:34 PM
The problem never was this html block:

<a href="index.php?action=chat">Chat here!</a>
<a href="index.php?page=10">Chat statistics</a>
<a href="index.php?page=17">Who's online now?</a>


It works just fine. The problem was the articles (page10 and page17 that is linked in the html block above.

Its working fine now. The problem was that I had php articles and used the "<?php" and the ending "?>" - without them it works fine.
Title: Re: Inject html file(s)
Post by: AmphetaMarinE on January 29, 2006, 08:51:41 AM
Ahhh ok...
Trust me to misunderstand it like the big ol dumbum i am..... :P