Jump to content

what is this behaviour: Template html replacement by id?


benbyf
 Share

Recommended Posts

I've not come across this before but in the default install for PW3.0.226 if you add some HTML into _main.php template file:

<div id="content">
  <?php // template code rendered here by PW ?>
</div>

and then add the same html container to the template named file e.g. home.php

<div id="content">
  <p>
	Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam mattis eros vitae metus sodales eget suscipit purus rhoncus. Proin ultrices gravida dolor, non porttitor enim interdum vitae. Integer feugiat lacinia tincidunt. Nulla laoreet tristique tristique. Sed elementum justo a nisl elementum sit amet accumsan nisi tempor. Nulla quis eros et massa dignissim imperdiet a vitae purus.
  </p>
</div>

when rendered I dont get double content containers but just one with the Lorem ipsum... What is this behaviour called??? Is there settings for it? Can it be disabled? confusing as hell.

  • Like 2
Link to comment
Share on other sites

Hi,

This is called Markup Regions, it's targeted to ease templating (like Twig would do but only in PHP): https://processwire.com/docs/front-end/output/markup-regions/

If you use this, prefer to do it with the pw-region tag as it is better optimized (check the documentation).

 

EDIT: I forgot to mention you can disable Markup Regions in site/config.php with $config->useMarkupRegions = false;
Then you may also want to disable $config->prependTemplateFile if this file is no longer necessary.

But if you want to use regions, you'll find in documentation that you can prepend/append/replace the _main.php tags with tags in templates, to solve the problem you are facing.

  • Like 8
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...