JoelB95 Posted April 24, 2018 Share Posted April 24, 2018 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! Link to comment Share on other sites More sharing options...
JoelB95 Posted April 24, 2018 Author Share Posted April 24, 2018 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. Link to comment Share on other sites More sharing options...
mr-fan Posted April 24, 2018 Share Posted April 24, 2018 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 3 Link to comment Share on other sites More sharing options...
rafaoski Posted April 24, 2018 Share Posted April 24, 2018 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> 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now