jtborger

Using markup regions causes template to render twice?

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!

 

Share this post


Link to post
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! :)

 

Share this post


Link to post
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.

Share this post


Link to post
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

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      Another little admin helper module...
      Template Field Widths
      Adds a "Field widths" field to Edit Template that allows you to quickly set the widths of inputfields in the template.

      Why?
      When setting up a new template or trying out different field layouts I find it a bit slow and tedious to have to open each field individually in a modal just to set the width. This module speeds up the process.
      Installation
      Install the Template Field Widths module.
      Config options
      You can set the default presentation of the "Field widths" field to collapsed or open. You can choose Name or Label as the primary identifier shown for the field. The unchosen alternative will become the title attribute shown on hover. You can choose to show the original field width next to the template context field width.  
      https://github.com/Toutouwai/TemplateFieldWidths
      https://modules.processwire.com/modules/template-field-widths/
    • By louisstephens
      I have done a bit of searching, but I can not seem to find an actual answer. I have a list of services as child pages under "Services". I can output the services just fine, but I cant wrap my head around how to group them "alphabetically" like:
      Services A - Service "A" 1 - Service "A" 2 - Service "A" 3 B - Service "B" 1 - Service "B" 2 - Service "B" 3 C - Service "C" 1 - Service "C" 2 - Service "C" 3 Has anyone achieved this type of functionality before?
    • By Falk
      Hi!
      I have lots of blogposts in my pagetree and I want the pagelabel to include the value of the post’s datefield (only the year).
      Adding date | title in the template settings results in something like…
      1536012000 | my blogpost title
      Is it possible to convert the timestamp to a readable date?
       
    • By mjut
      Hello!
      I am trying to get some extra css-file into my admin templates. I managed to modify my admin.php to this:
      <?php namespace ProcessWire; require($config->paths->adminTemplates . 'controller.php'); echo "<link rel='stylesheet' type='text/css' href='" . $config->urls->templates . "css/admin.css'>"; By doing so, the css <link> is added to the very end of each parsed admin-html. (right AFTER the closing </body> tag.)
      That causes some trouble. e.g. the page tree is not displaying any more. Although, other pages are working - like the edit form of a page.
      My question: is there a correct way of adding my extra css to the admin area?
      Thanks for you help!
      Stephan
       
    • By karian
      I don't know why multiple instances (repeater_repeat_columns1, repeater_repeat_columns2, ...) of my repeater field are displayed inside Template field (see image).
      Is there a way to clean/reset it ?