Jump to content

Using markup regions causes template to render twice?


jtborger
 Share

Recommended Posts

Hi,

Yesterday I found out about the relatively new markup regions functionality and I love it. The ease of use and simplicity is just what I think is typically ProcessWire and is why Im still happy I chose for PW four years ago when changing CMS/CMF. So thanks Ryan for your vision and all you put into it.

That said, Im running into an issue I'm not sure what to think of it.

 

I have enabled markup regions in config.php and it does what I suppose it should: it replaced and all. Very neatly. 

The only thing I discovered is that while Im debugging some issues and I use var_dump to echo some stuff, it does that two times in a row. And this only happens when useMarkupRegions is enabled.

I dont get this, does it mean the template file gets called twice (and thus the script is run twice?) or is it only displayed twice, where the first time most output is erased and /or replaced by the substituted output?

I don't really get whats going on there. Is this behavior normal when using markup regions?

Thanks!

 

Link to comment
Share on other sites

Hi Karl,

Thanks for pointing this out to me. I had searched the forum and couldn't find anything about this. It seems that the issues you filed and my question here is the same thing... And Ryan's explaination seems fine, though I have one question for Ryan (hope he'll read this):

Indeed I output some stuff before doctype, which is tried to being rendered as a markup region as I understand from your comment on the issue Karl mentions above. Since it cannot be substituted, it gets displayed anyway, as I understand it.

But, why does it gets displayed the first time then anyway? It feels illogical to me to be honest. I understand that all output before doctype is seen as if it should be put in a region later on, and when not, it gets displayed. But shouldn't it be removed from output first, then searched for a region to be put in, and if not, then outputted anyway? Perhaps this logic is too advance/heavy since replacement gets done by regexes I think, but anyway.... just a suggestion. 

Perhaps I don't understand it correctly anyway so please excuse me for this... I still find it a very neat solution anyway! :)

 

Link to comment
Share on other sites

As far as I know the documentation says you should change the /sites/config.php. This also generates double output for me.

That never worked for me. I change /wire/config.php. Downside is that with every update I would need to change it again.

Link to comment
Share on other sites

11 hours ago, jtborger said:

while Im debugging some issues and I use var_dump to echo some stuff

Check out Tracy Debugger and you'll be glad you did. Then rather than using var_dump and echo you can use the bd() function in your files to get a lovely expandable dump output and the "double output" thing won't be an issue with Markup Regions.

2017-11-19_094145.png.76910436a4aada9201b89155bccc9565.png

  • Like 5
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...