Execute PHP code in HTML-Bloock possible?

Permalink 1 user found helpful
Hello,

I am not able to execute any PHP-Code within my (themed) site.
I am using c5.4.1 with theme Earthling Two
(http://www.concrete5.org/marketplace/themes/earthling_two/)

I use the HTML-Block for that and edited e.g.
<?php echo "Hello World."; ?>
The Problem is, when I look into the source code of my page it looks like:

<body>
[...]
<div id="HTMLBlock92" class="HTMLBlock">
[...]
<?php echo "Hello World."; ?></div>
[...]
</body>

It's just not beeing executed, I can see nothing.
With any php code I do.

I tried the a block called "PHP Code" but I get the following error message on my page:

Fatal error: View::render() [<a href='view.render'>view.render</a>]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition &quot;PHPCodeBlockController&quot; of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in /kunden/120987_64546/rp-hosting/8390/10160/concrete5/concrete/libraries/view.php on line 734

You can try for yourself here:
http://salajean.de/concrete5/index.php?cID=72...

Any suggestions?

Regards
Prof.P

profp30
 
jgarcia replied on at Permalink Reply
jgarcia
The HTML code cannot execute PHP. If the PHP code block is not working for you, you could contact the developer of that block...they should probably get that fixed anyways :)

Outside of that, you would need to use single pages or find another block to help you accomplish whatever you are trying to do.
Remo replied on at Permalink Reply
Remo
There's this block as well:
http://www.codeblog.ch/de/2008/10/concrete5-block-code-ausfuhren/...

In case you don't speak German, there's a download in the last page which links to this:
http://www.codeblog.ch/wp-content/uploads/2009/11/php_execute.zip...

You can't enter the code in the block dialog but that would make it a bit dangerous. Imagine if your customer could execute any php code on your server. The block works by executing PHP files which you have to create on the file system.
melat0nin replied on at Permalink Reply
melat0nin
Hi Remo

Your block doesn't seem to be working in concrete 5.4.2 - any ideas how to fix it?

Thanks!
Remo replied on at Permalink Reply
Remo
Can you please be a bit more precise? What doesn't work? Can't you add it? Is there an error message?
melat0nin replied on at Permalink Reply
melat0nin
Hi Remo

Sorry, yes, I should have been more specific. When I upload the block's directory to packages/ on my server it doesn't appear in the Add Functionality screen of the Dashboard. I've checked the permissions and they seem fine (755).

I'm running a fresh installation of 5.4.2.
Remo replied on at Permalink Reply
Remo
I don't think the example I've posted on codeblog is wrapped in a package, it's just a block, nothing else.

But that's not related to 5.4.2.. Just try to copy it to /blocks as see if that changes anything!
melat0nin replied on at Permalink Reply
melat0nin
Hi Remo

You're right, it's just a block and works by putting it in the blocks/ directory (and i'm an idiot!)
jpullman replied on at Permalink Reply
Just wanted to say, thanks a lot. I really needed this and it worked out for me.
pvernaglia replied on at Permalink Reply
pvernaglia