1
sheffel
Custom Block Erroneously Displays PHP/HTML Source Code
  • 2003/12/14 5:32

  • sheffel

  • Just popping in

  • Posts: 3

  • Since: 2003/12/14


I have created an XOOPS block and inserted PHP code (or PHP embedded in HTML tags), with varying results. The error is, that, a portion of the raw PHP code gets displayed in the user viewed block. The ironic thing, is, that the PHP code is displayed correctly in the separate pop-up Preview window (well, sometimes, depending upon if PHP or HTML code and block setting of PHP or HTML option setting). Yet, it only displays some of the raw PHP code (the first several lines are not displayed).

I turned on PHP debug, and nothing was apparent. (I can't get FreeContent to display HTML code either, hmmm?)

What I would really like to do, is, point the block source PHP to a file (of PHP code) and have the XOOPS block run the PHP code from the file. (Then, I could more easily modify the file, and have the XOOPS block render the PHP code.)

Something obvious must be misconfigured - since the use of this feature seems pretty much a key feature to Xoops! (Right?)

Thanks for any advice, in advance.

2
mvandam
Re: Custom Block Erroneously Displays PHP/HTML Source Code
  • 2003/12/14 6:05

  • mvandam

  • Quite a regular

  • Posts: 253

  • Since: 2003/2/7 2


I've never actually used the custom block feature , but I think you cannot put PHP code inside an HTML block.

i.e. XOOPS just spits out the contents of the block, and your webserver cannot intervene to interpret the PHP.

Instead set it as a PHP block. For your code you should be able to "include" your desired file (HTML and/or PHP). i.e. just put: include "somefile.html"; in your block. (Or .php or whatever.)

I think.

3
robekras
Re: Custom Block Erroneously Displays PHP/HTML Source Code
  • 2003/12/14 10:00

  • robekras

  • Documentation Writer

  • Posts: 187

  • Since: 2002/12/10


I think a simple
Quote:

include "somefile.html";

will not work.

If you have an PHP block you can only output something with
echo or print.
So I think you have to read the somefile.html into a variable and then output it by an echo.

Something like this:
Quote:

$html = file_get_contents ("somefile.html");
echo $html;


Take a look at PHP Docs for file () and file_get_contents ().


4
CBlue
Re: Custom Block Erroneously Displays PHP/HTML Source Code

I use include('somefile.php'); in my custom blocks and it works. I use a php file in a block on my site and it rotates my amazon affiliate images in it with their affliate links connected to the images.

See it here http://magazine.crazy4realitytv.com/ towards the bottom of my left column. The title of the column is Reality TV Items and images rotate in that block for me using the include and saving the block as php.

You can also use the include like this: include('somefile.html'); for html files you want to show up in the block, saving it as php or write the html code in the block and don't use or tags in it and save the block as html.

Login

Who's Online

343 user(s) are online (244 user(s) are browsing Support Forums)


Members: 0


Guests: 343


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits