Jump to content

Recommended Posts

Posted

Hi everyone,

I'm new to processwire and I'm trying to figure some things out. I really like the idea of markup regions but everytime I end up with some double executed PHP scripts. 

This is in my config.php

$config->useMarkupRegions = true;
$config->appendTemplateFile = '_main.php';

This is the markup element in my _main.php

<div id="page-content">
  <!-- Fill content -->
</div>

This my overview.php template

<?= 'test' ?>
<div id="page-content">
	<h1><?=$page->title?></h1>
	Overview page
</div>

If I add some php code to the _main.php or overview.php template, it will be executed twice. For example, like in overview.php, when I echo 'test' at the top of this file, it will output testtest at the top of my page (I added a screenshot). However, the page title will only display once. I also had this problem in my _func.php file. I do not really understand where I have to include my _func.php file now, while using markup regions. In the config or main? Or somewhere else? Can anyone help me into the right direction? Thanks!

Screenshot_56.png

Posted

Additional info: I understand that all content has to be inside the page-content id, but this is just an example. If echo 'test' at the top of my _main file or in my _func file, the same thing happens.

Posted

In your example @JoelB95, just use pw-before ...

<div pw-before="page-content">
	<h1><?= 'BEFORE #page-content' ?></h1>
</div>

<div id="page-content">
	<h1><?=$page->title?></h1>
	Overview page
</div>

<div pw-after="page-content">
	<h1><?= 'AFTER #page-content' ?></h1>
</div>

 

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...