Problems with including PHP

Permalink
Hello community!
I've got a problem including a php file in my site.

I've got some functions allowing me to simply open and close a container as surrounding for the actual content.

I'm including this code in my header.php on the very top of all.

The problem is, I'm trying to use the function inside of the view.php of a block type and it just randomly doesn't work.

Here's what I did:
I opened the page and everything worked fine so I entered the edit mode. After editing some content and closing the form (back into edit view), it stops working saying the function is not defined while the page uses exactly this function to create the surrounding of that error message .....

So I tried to include it in my block by adding
<?php
$this->inc('rounded_container.inc.php');
?>


(After copying the file into block folder) Concrete5 tells me to not double include that file please.

What the heck? :D

How can the function be defined for the page AND the block when viewing but gets lost for the block after editing it ??

Thanks guys,
Slap

SlapY
 
SlapY replied on at Permalink Reply
SlapY
Hey folks,

I think I know what the problem is and maybe anyone can help me develop a work-around.

The problem seems to be, that C5 is AJAX-Getting the new rendered content of my block type so the needed include is not available.

What could be a solution?

- Including my PHP include in controller.php and my page template using require_once (!) - so the file will only be included twice by template and ajax-rendering ?

- Including my PHP include inside of the view.php? (In case controller isn't loaded when ajax-getting the rendered content ?

- Another way of global including ? Like an include in all contexts of C5? Is such a thing possible?

- I'm doing it all wrong

Thanks,
Benjamin