Making PHP driven sites with Blocs

HI,
I’m new to Blocs - it looks interesting - different to what I’m used to (Freeway) - but I’d like to see what I can and can‘t do.

One thing I do is quite a bit is create dynamic sites - content will come from a database, processed by some PHP and then output.

There are a few things I can’t see how to do in Blocs. Currently on the trial download which is 2.4.4.

1 - Include PHP pages before any of the real page begins. Useful if you don’t need to redirect to another page before any headers are sent out:
eg:

<?php
include "pathto/script.php";
?>
<!doctype html>

I don’t see any method that lets me do this.

2 - Is it possible to insert a Bloc which then takes input from a PHP loop? For example, a list of products on a page with a photo, price, buy button? There are a few Blocs that look like they could form the basis of this, but I don‘t see a way to include a PHP loop structure, and have that element repeated number of times (where n = the number of products captured from a database).

Is is possible to create my own Bloc based on existing ones that can add this kind of functionality?

3 - Including PHP variables in text - eg:

<p> Hello, $name</p>

becoming functional, eg:
<?php
echo <<<END

Hello, $name


END;
?>
or
<p>Hello <?php echo $name; ?></p>

Being able to drop in PHP variables into places would be useful - form elements, image URLs, etc. etc…

I’m looking at this from the perspective of someone who has lived and breathed web work in Freeway since the 1990s, and while that app is kind of still around, I’m feeling that I need to be looking at alternatives. I have a certain way of working, and if I can indeed find that Blocs can do what I want, I’ll very likely buy a copy.

Five day trial to see if it will answer all my questions though… Certainly being able to cover the points above will be a big nudge in Bloc’s favour. I’d love to be able to produce a dummy site that covers the above points to I can see what’s what.

Thanks!

I use php includes in the html widget. For stuff that needs to be at the top, it’s coming, but for now you’ll need to add it in post. I use BBEdit text factories to automate the process.

1 Like

Any idea when this feature is going appear?

A little birdie told me 2.5.

1 Like