How to combine site-wide logic/security in header php include?

In other systems I’ve worked with, I have been able to add lots of “site-wide” logic into an include so it’s used on all pages and only requires editing in one place – the include.

The issue I’m finding with Wappler is that the includes do not easily allow you to add things like the code below since it’s above the opening HTML tag. I want this in my header, but if I’m using routing then Wappler is adding an ac:route in the <head>.

Is there a way to make the route dynamic?
Is there a way to make the other meta tags (e.g.e og:description) dynamic too?

If there is, then I could make an include for all of it and make my sites quicker to build and easier to maintain.

<?php
require('dmxConnectLib/dmxConnect.php');

$app = new \lib\App();

$app->exec(<<<'JSON'
{
	"steps": [
		"Connections/videdit_db_dev",
		"SecurityProviders/siteSecurity",
		{
			"module": "auth",
			"action": "restrict",
			"options": {"loginUrl":"signin","forbiddenUrl":"signin","provider":"siteSecurity"}
		}
	]
}
JSON
, TRUE);
?>

For the Security part, this is what I add to each of the protected pages:
<?php include_once('inc/security.inc.php') ?>

Thanks @ben. Is that different from the code I have above or the same thing?

The file security.inc.php contains the code that you have shown. The include part simply includes the content of that file into your document.

2 Likes

Hi Kfawcett,
Were you able to achieve what you are trying to do. I also trying to include_once into a header, i am finding it difficult. Please let me know if and how it work for you.

Sincerely
Bankym