psy

Regions on basic page

Recommended Posts

psy    154

I am using regions with the tag <region id="whatever"> in the _main.php file. Config file is set up as follows:

$config->useMarkupRegions = true;
$config->prependTemplateFile = '_init.php';
$config->appendTemplateFile = '_main.php';

When I use a page template that changes a region, all goes well. However, I set up the _main.php file to reflect the output for a basic page. The basic-page.php template needed no customisation so was simply as follows:

<?php namespace ProcessWire;
?>

When a page with the basic-page template was output, all the <region> tags remained in the HTML, ie were not stripped.

When I added a customised region to the basic-page.php template, all the <region> tags were stripped from the output _main.php HTML.

Did I do something wrong or is this a bug?

Using ProcessWire 3.0.63 © 2017 

 

Share this post


Link to post
Share on other sites
psy    154

Quick workaround... in _main.php add

<region id="dummy"></region>

in basic-page.php add

<region id="dummy"></region>

Seems PW needs a region in the page template to kick-start the process.

  • Like 3

Share this post


Link to post
Share on other sites
maxf5    43

is there still a bug? Same problem here on Processwire 3.0.69


$config->useMarkupRegions = true;
$config->prependTemplateFile = '_main.php';

in _main.php
 

<?php namespace ProcessWire; include_once("./_init.php"); ?>

....

<region id="dummy">
  <h1><?php echo $title; ?></h1>
  <?php echo $teaser; echo $content; ?>
</region>


in basic-page.php

<?php namespace ProcessWire; ?>

<p pw-prepend="dummy">
  123
</p>

 

Voila:

Unbenannt33333333.PNG.fb02cf29cca6dafd8eb0865dee9dd213.PNG

  • Like 1

Share this post


Link to post
Share on other sites
szabesz    1,389

@maxf5 Did you try it with <pw-region> too? Sure, they should be the same, but still...

To tell the truth, I never really understood why having all these variations of the same thing is good. It just makes things more confusing, more time to debug but adds no additional feature. It's like having similarly named methods doing the same thing. Well, at least they are supposed to do the same ;) 

Share this post


Link to post
Share on other sites
maxf5    43

@szabesz , yes.. some problem with <pw-region>

in _main.php

<pw-region id="something">
...
</pw-region>


in basic-page.php

<p pw-append="something">
  12123123123
</p>

and you get:
Unbenannt33.PNG.26ad4c103b1394b8055261c048ef5f4d.PNG

Settings:
$config->useMarkupRegions = true;
$config->prependTemplateFile = '_main.php';
ProcessWire 3.0.69 

PHP VERSION 7.0.18

 

 

  • Like 1

Share this post


Link to post
Share on other sites
maxf5    43

Is there any solution to make MarkUpRegions work when you have your general markup in prepended or appended files, @ryan ?

I am really excited about this feature and cant use it so far

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 EyeDentify
      Simple example for loading template specific CSS file.
      This example asumes that you have your CSS file in a directory relative to template root.
      Like:
      templates/css/my_template_specific.css
      Also i use in the template a simple text field to hold the name of the CSS file i want to load.
      I call this field 'css_file'
      Use what you feel comfortable with.
      So in your header section of the DOM notice the "page specific CSS" part?
      Thats were the magic happens. What happens is that we check to see if the file exists in the CSS dir relative to template root.
      And if it does we load it. Simple and effective.
      I load all other CSS that is used all over the site in global_styles.css first.
      And make sure you load template specific last, because then you can easily override CSS in global.
       
      DOM header example:
      <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title><?PHP echo($page->title); ?></title> <!-- main CSS --> <link rel="stylesheet" href="<?PHP echo($config->urls->templates); ?>css/global_styles.css"> <!-- page specific CSS --> <?PHP /* Use relative path in file_exists() */ if(file_exists('css/' . $page->css_file)) { echo("<link rel=\"stylesheet\" href=\"{$config->urls->templates}css/{$page->css_file}\">"); } ?> </head> <body> Thats my way of doing it. I am sure there is plenty of more ways to do it. This is for the newbies or anyone that wants more options.
      Good luck with your CSS out there in Cyberspace.
      Cheers from EyeDentify
    • By zaib
      I've a page "blog" which have child pages (blog posts). Right now I've 11 pages (blog posts) and I'm fetching all the posts in my "blog" pages which displaying fine, Issue is only 10 results are showing this is how I'm fetching
      $entries = $pages->find("template=blog-entry"); foreach($entries as $entry){ <a href='{$entry->url}'>$entry->title</a> }  
    • By MilenKo
      Hello all. I know it might sound silly, but wanted to check how are you guys proceeding if in the theme development you have a need of some fields that are repeating in several templates. For example, I am having an image field that can be used as the site logo in "Settings" template or as to show the page image in the markup of the inner page template or else. I am aware, that if I leave the resizing in the markup, than the field can be used on multiple templates, but the field has some specific label/description, notes and/or placeholder that would be not-related. 
      Sticking to the logo example, I have a label saying: Add your logo image here. So if I use the same field for something else, the same text would show while editing the new next page calling for image.
      How are you guys taking care of this? Are you creating specific fields for every aspect of your theme or there are some tricks I am missing in the big picture?
      P.S. Besides the descriptive text of the field some might require to have a single image and some an array (e.g. you don't need to upload multiple logos, unless you want to randomize or call one based on some criterias, but for a gallery - sure I would have multiple)
    • By mike62
      I'm new to PW... I'd like to have some blog posts displayed on our homepage based off the attached mockup.
      I want each post to use a slightly different layout.
      Is this possible?

    • By rocket
      Noob to Processwire. Trying to convert some older sites to Pwire. I am having trouble including a legacy form class into my templates:
      If I embed the php directly in the template, it works. But if I use include statements, the form object returns null.
      This works:
          use formbuild\Form;
          session_start();
          $form = new Form(init1, 'init2', ...');
          $form->param1 = ...;
          $form->param2 = ...;
          $form->param3 = ...;
       
          $form->render();
      -----------------------------------------------------------------------------------------
      This fails:
          include_once ($config->paths->templates."forms/form1.php");
          $form->render();
      ____________________________________________________________________
      My referencing is OK, no error message. The only code that cannot reside in the include file are the following lines:
          use formbuild\Form;
          $form = new Form(init1, 'init2', ...');
      My PhP is rusty, maybe that is the problem, but it could be something about Pwire, namespace maybe. I have tested it outside Pwire and no problems.
      Please advise. Thanks.