Jump to content
darrenc

make a markup region be removed from markup, not just empty?

Recommended Posts

lets say, in _main.php I have some placeholder regions for content/sidebar

<div id="content">foo</div>
<div id="sidebar">bar</div>

in my home.php template, maybe i don't want the sidebar div at all. But when I put in the intentionally blank code

<region id="sidebar"></region>

I simply make my sidebar div blank, it doesn't remove it.

Q: Is there a slick way to simply nuke that div#sidebar entirely from markup?

Share this post


Link to post
Share on other sites

@darrenc Yes 'pw-remove' works.

Maybe it's about being consistent? Try using the <region> tag for all rather than mix-n-matching <region> & <div>

Instead of using

<div id="sidebar"></div>

use

<region id="regSidebar">
  <div id="Sidebar">xxx</div>
</region><!--regSidebar-->

Then in your template where you don't want to display the sidebar, simply put

<region id="regSidebar"></region>

This has always worked for me and helps me keep track of the regions. Many roads up the mountain 🙂 

 

 

 

 

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By rushy
      Hello. I have recently adopted PW markup regions and really like this way of working. However, I am also trying to learn how to use Ajax and I am not sure of a good way to use the two together. Has anyone got any experience, tips or hints on using them together? For ajax -  I've used a simple scheme where I have a "webservice" template and page that handles Ajax requests and returns the appropriate content wrapped with some markup for the requesting page. I have markup regions enabled and all my pages (bar webservice) include a _main.php which brings in the headers, a default body and the footer. My javascript intercepts the page links and does my ajax call to webservice and that sends back the appropriate markup which is then placed by in the div #body defined in _main.php.  Does this seem a reasonable way to work? I guess I am looking for some advice before I invest too much time going the wrong way!
      Any guidance, remarks,  comments, or a nudge in the right direction greatly appreciated.
      Paul
    • By Moritz Both
      Greetings!
      For our PW project we use markup regions and, for one template, url segments. The documentation recommends throwing a new Wire404Exception() from the template when the code concludes that the url segments from the request are invalid, and so we do.
      However, the 404 page is not displayed properly. Viewing the page source in the browser we can see that the original, unmodified markup region contents from our _init.php file is prepended to the correct html output, messing the whole page up.
      Any advice is greatly appreciated.
    • By EyeDentify
      I as have been a bit confused for some time about how the "Markup Regions" functionality in Processwire worked.
      But i have know read a bit more and think that i am getting to grips with it. And Markup Regions is going to be huge.

      To aid me in understanding Markup Regions better i started to read the Source code for the new "Regular" theme in conjunction with the Blog about the markup regions.
      It helped me a great deal to understand the basics and more fine details of it.

      A tip is to open both links and use the Source code of the "Regular" theme while reading the blog post.
       
      The Source code:
      https://github.com/processwire/processwire/blob/dev/site-regular/templates/_main.php
      The Blog post:
      https://processwire.com/blog/posts/processwire-3.0.62-and-more-on-markup-regions/
       
      I hope this could help others starting out with markup regions.
      Just take it slow and read it a couple a times and soon you will see the greatness of markup regions.

      /EyeDentify 
    • By jtborger
      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!
       
    • By John W.
      This question has probably been beaten to death - think I'm approaching this wrong. 
      Anyway, I've got a textarea input field that uses ckeditor.
      Under the fields Input section I managed to add my custom style sheet in the 'Custom Editor CSS File (regular mode) section for instance:
      /site/templates/css/ckeditor.css

      This seems to work fine.
      What I'm trying to do now is add a custom style to the ckeditor styles menu, for instance, called .green_button
      (p.s. in the ckeditor styles.js I added this to the inline section : { name: 'Green Button', element: 'a', attributes: { 'class': 'button' } },
       
      Ok, onto the problem...
      I notice that PW, by default, is using  /wire/modules/inputfield/inputfieldCKEditor/ckeditor-4.5.10/styles.js
      So, I copied this into /site/templates/js/mystyles.js
      Next, I added the above to the 'Custom Editor JS Styles Set' field, however, it doesn't seem to load myckeditorstyles.js -- rather continues to load the one from the /wire/modules... folder.
      I cleared all history and caching in Safari (also tried Chrome, etc).

      I'm wondering if there is something else I need to do to have PW load my /site/templates/js/myckeditorstyles.js instead of the one in /wire/modules.../ckeditor-4.5.10/styles.js ?

      Thanks!
       
       

×
×
  • Create New...