I think it would be helpful if Elements could automatically include the code:
<?php
ob_start();
?>
At the front of the page file (i.e. before the statement) if a custom HTML component had a way of requesting this, maybe by a hidden property?
Doing this would enable HTML components using PHP code to get things done before the page starts by using the PHP ob_ related commands in a custom HTML component without having the user having to put the code into the site prefix. So typically (thinking RW Classic, Stacks and Foundry 3) this would involve adding an initialising stack to the page to initialise whatever the function that a group of stacks were supporting.
The equivalent in Elements would be to add a custom HTML component that would do the initialisation, that might require the use of PHP ob_start(), for a set of related custom HTML components.
Interesting idea, although that is a VERY specific feature request. We have the “Prefix” code box (that should be working in the next beta) - would that not do the job for you?
Yes, you are correct, that will work and it is what I am doing at the moment but you don’t have to do this with Stacks and Foundry 3, for example.
If I was selling (I am not!) a group of custom components to do a function like a blog or something that required PHP to initialise something at the start, the user should just be able to drag the required components onto the page and not have to go and edit code in the Systems Settings > Code > Prefix. I think that would potentially be inviting more support requests and user dissatisfaction when things go wrong?
Extending this idea further would be to allow a Custom HTML Component to specify the PHP code that is to be added to the site prefix. This would be more generalised. I am thinking of a 3rd party developer adding functionality to Elements in a user friendly way without the user having to add code to the site prefix themselves.