evanmcd Posted March 28, 2017 Share Posted March 28, 2017 Hi all, Just found my first use case for new Markup Regions (at least I think that's what they're being called) feature. Unfortunately, I haven't been able to get it working. I'm using 3.0.57 and have added the $config->useMarkupRegions = true; line to my config file. Next, I put the id in my head tag like so: <html lang="en"> <head id="html-head"> Then the markup in the template file (the head tag is in top.php): <?php include("inc/top.php"); ?> <head id="html-head" class="pw-append"> <link rel="stylesheet" type="text/css" href="/site/templates/css/calculator.css"> </head> When I reload the page that uses the above template, I get that unprocessed code output right after the output of my top.php file - in other words exactly what would happen if there were no such thing as Markup Regions. Am I missing something? I've read through the post here, and I seem to be doing everything needed. Thanks for any help. Link to comment Share on other sites More sharing options...
Robin S Posted March 28, 2017 Share Posted March 28, 2017 The following quote from the blog post is useful in understanding how your templates need to be structured in order for Markup Regions to work: Quote When ProcessWire renders a page, it now asks the question: does any markup appear before the doctype or <html> element? And if it does, does any of it reference "id" attributes or have "pw-" prefix classes? If so, it processes them as markup regions, letting you do all that's mentioned in this post. So the general rule is: the place where you define your 'original' markup regions (that you will append to, etc, in your template files) needs to have the doctype or <html> element in it, and it needs to be the last piece of markup to be rendered. That's why your markup regions would typically be originally defined in an auto-appended "_main.php" so that it is rendered last, and any markup that you are echoing or outputting in your template files will reference those regions and appear before the doctype/<html> of _main.php. 2 Link to comment Share on other sites More sharing options...
ottogal Posted March 28, 2017 Share Posted March 28, 2017 Quote <?php include("inc/top.php"); ?> <head id="html-head" class="pw-append"> <link rel="stylesheet" type="text/css" href="/site/templates/css/calculator.css"> </head> @evanmcd You say Quote the head tag is in top.php So it seems you get the head tag twice. Link to comment Share on other sites More sharing options...
evanmcd Posted March 28, 2017 Author Share Posted March 28, 2017 @ottogal, yes but isn't that the syntax for using markup regions? The 2nd head tag should be removed by PW prior to rendering as I understand it. Link to comment Share on other sites More sharing options...
evanmcd Posted March 28, 2017 Author Share Posted March 28, 2017 Ahhh, sorry, didn't see @Robin Ss post until after I replied. I'll give that a shot. Thanks for the tip. Link to comment Share on other sites More sharing options...
ottogal Posted March 28, 2017 Share Posted March 28, 2017 @evanmcd You're right, of course - sorry for my stupid intervention. Link to comment Share on other sites More sharing options...
evanmcd Posted March 30, 2017 Author Share Posted March 30, 2017 Oh no problem at all @ottogal. Just tried moving the appended region code above my top.php and it worked as @Robin S predicted. Not sure why I didn't just try that before In any case, thanks for the help. I see myself using markup regions with all my sites going forward. So much cleaner that other methods. 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