Jump to content

Markup region - Some scripts executed twice


JoelB95
 Share

Recommended Posts

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

Link to comment
Share on other sites

https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/

try in main

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

and like the blogpost in overview

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

it should work this way...you have a lot of other options like append, prepend and so on...

best regards mr-fan

  • Like 3
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
 Share

×
×
  • Create New...