SimplePortal

Support => English Support => Topic started by: vas on February 17, 2011, 04:44:47 AM

Title: Why html Code gets truncated when embedding in a page!
Post by: vas on February 17, 2011, 04:44:47 AM
I am using SMF2 RC4 and Simple Portal 2.3.3

I tried to use the following attached code in a Simple Portal Page  and the code gets truncated even though it allows full preview. Because of this, only half the page is produced when the page is displayed.

When you look at the code using edit, you see only half the code is saved.

Is there a limitation in Simple Portal in regard to number of lines etc.,

For your info, I am trying to use a table from Excel converted by MS-Office to HTML format

Since the code is very lengthy, I have enclosed here as attachment.

Thanks for response.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: AngelinaBelle on February 17, 2011, 10:26:10 AM
There are a couple of problems with that HTML
1) It is an entire page.
    Because an HTML block appears on a page of your forum, it should only contain the stuff that goes inside the <body> tag.  That means no <style> tags.  Anything you want between style tags, you can put in a CSS file. Of course, CSS files are loaded BEFORE the body tag. So the only way to add that CSS link in the head where it belongs from within your HTML block is by using a little javascript to do it.
 
2) It is, indeed, quite long.  Over 2000 lines. How long can the page text be? I just looked in install2.php to see that the body column of the pages table is of type text. Then I checked the mySql manual to find out that TEXT fields can hold 2^16 (=65536) characters. So that's your limit.
 
One way to get around this limit is to save your HTML to a file. Use a php block. Open the file and echo its contents to the screen.
Code: [Select]
if ( $filearray=file($FileName) )  echo implode($filearray,'');
else echo "Could not open file <b>$FileName</b>. <br /> \n";
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: vas on February 18, 2011, 05:34:25 AM
There are a couple of problems with that HTML
1) It is an entire page.
    Because an HTML block appears on a page of your forum, it should only contain the stuff that goes inside the <body> tag.  That means no <style> tags.  Anything you want between style tags, you can put in a CSS file. Of course, CSS files are loaded BEFORE the body tag. So the only way to add that CSS link in the head where it belongs from within your HTML block is by using a little javascript to do it.
 [/code]
Thanks for this advice.

2) It is, indeed, quite long.  Over 2000 lines. How long can the page text be? I just looked in install2.php to see that the body column of the pages table is of type text. Then I checked the mySql manual to find out that TEXT fields can hold 2^16 (=65536) characters. So that's your limit.
 
One way to get around this limit is to save your HTML to a file. Use a php block. Open the file and echo its contents to the screen.
Code: [Select]
if ( $filearray=file($FileName) )  echo implode($filearray,'');
else echo "Could not open file <b>$FileName</b>. <br /> \n";
I will implement this, see how it works and give here the feedback.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: AngelinaBelle on February 23, 2011, 10:06:39 AM
Please post again when you have an update on this issue.
Thanks
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: Yngwiedis on April 17, 2011, 12:54:26 PM
Hello...

I have almost the same problem with vas.
I have a very large html table which i want to be displayed on a page.

I try the solution you suggest with this code:

Code: [Select]
if ( $filearray=file($FileName) )  echo implode($filearray,'');
else echo "Could not open file <b>$FileName</b>. <br /> \n";

but i get errors like this :

Code: [Select]
Parse error: syntax error, unexpected ':' in /home/xxxxx/public_html/Sources/PortalBlocks.php(3386) : eval()'d code on line 1
can you point me in the right direction ?

Thank you very much.

Title: Re: Why html Code gets truncated when embedding in a page!
Post by: AngelinaBelle on April 18, 2011, 08:40:56 AM
Sorry. This fragment was just a suggestion, not a well-tested solution.
Of course, you must say what your fileName is before you use it.

If you've already got an HTML file, maybe your easiest solution is just to use an iframe tag to include it in the page.
http://www.google.com/search?q=iframe+tag
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: Yngwiedis on April 18, 2011, 10:44:17 AM
I dont want to use an iframe.

The filename will be .html ?
Or something else ?

so the code will be something like this ?

Code: [Select]
if ( $filearray=myfile.html($FileName) )  echo implode($filearray,'');
else echo "Could not open file <b>$FileName</b>. <br /> \n";

Thank you very much.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: [SiNaN] on April 19, 2011, 05:35:18 AM
Run this query via phpMyAdmin:

Code: [Select]
ALTER TABLE smf_sp_pages
CHANGE COLUMN body body MEDIUMTEXT

That should increase the field limit to ~16 million characters.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: vas on April 19, 2011, 07:43:43 AM
Run this query via phpMyAdmin:

Code: [Select]
ALTER TABLE smf_sp_pages
CHANGE COLUMN body body MEDIUMTEXT

That should increase the field limit to ~16 million characters.

I will try this. Will this any way reduce the speed of loading the portal pages!?

Before I saw SiNaN message, I found a different way out.  Even though it did not fulfill what I wanted (I want the simple portal page to have a html) it served the purpose of having SMF header and footer and avoided moving out of the forum to see the html page. The solution I found is from
Creating own HTML page between SMF header and footer ?? (http://www.simplemachines.org/community/index.php?topic=333243.0)
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: AngelinaBelle on April 19, 2011, 08:10:17 AM
Code: [Select]
$FileName='myfilename.html';
if ( $filearray=file($FileName) )  echo implode($filearray,'');
else echo "Could not open file <b>$FileName</b>. <br /> \n";

You can usually decrease the time to load portal pages by decreasing the number of  blocks on the page.
You can go through, one by one, to find out which ones slow things down the most.
 
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: [SiNaN] on April 19, 2011, 08:15:24 AM
I will try this. Will this any way reduce the speed of loading the portal pages!?

Did you mean "increase" perhaps? I read it that way, initially.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: Yngwiedis on April 19, 2011, 10:23:18 AM
Code: [Select]
$FileName='myfilename.html';
if ( $filearray=file($FileName) )  echo implode($filearray,'');
else echo "Could not open file <b>$FileName</b>. <br /> \n";


This is not working for me.
I always get "Could not open file" error.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: vas on April 19, 2011, 12:14:55 PM
Did you mean "increase" perhaps? I read it that way, initially.

I apologize my statement was ambiguous. What I tried to mean is "Increase the field limit to ~16 million characters anyway adversely affect the speed of loading a web page?"

Will it take more time to load any (and every page) - even those which do not contain data that exceed the present field character limit, due to bigger data field in the mysql?
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: [SiNaN] on April 20, 2011, 08:17:34 AM
This is not working for me.
I always get "Could not open file" error.

Where do you upload the HTML file, exactly?

I apologize my statement was ambiguous. What I tried to mean is "Increase the field limit to ~16 million characters anyway adversely affect the speed of loading a web page?"

Will it take more time to load any (and every page) - even those which do not contain data that exceed the present field character limit, due to bigger data field in the mysql?

No, it shouldn't slow down the page load. You may only experience issues with PHP memory limit when you have pages more than ~4-5 million characters, and that's only if you have the limit set as low as 8-16MB. So it should be fine.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: vas on April 21, 2011, 02:00:19 AM
No, it shouldn't slow down the page load. You may only experience issues with PHP memory limit when you have pages more than ~4-5 million characters, and that's only if you have the limit set as low as 8-16MB. So it should be fine.

Thanks for the information.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: [SiNaN] on April 21, 2011, 04:58:05 AM
So did that solve your issue?
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: allison on April 23, 2011, 05:39:03 AM
nvm - changed the name and its working.
Thanks
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: [SiNaN] on April 24, 2011, 07:50:43 AM
Glad that it worked for you.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: vas on April 25, 2011, 07:42:02 AM
So did that solve your issue?
Thanks for your help SiNaN. It worked. The issue is solved using the code you provided.

Quote
Run this query via phpMyAdmin:

Code: [Select]
ALTER TABLE smf_sp_pages
CHANGE COLUMN body body MEDIUMTEXT

Thanks once again. :applause:

One follow up query: Before it being converted to MEDIUMTEXT what the field type was. Just Curious.
Title: Re: Why html Code gets truncated when embedding in a page!
Post by: [SiNaN] on April 25, 2011, 09:06:46 AM
You're welcome.

The field type is TEXT by default, which is limited to 65535 characters.
SimplePortal 2.3.8 © 2008-2024, SimplePortal