Jump to content

Small tip for pages that will be used with render()


Recommended Posts

Posted

If you are planning to build a template for pages that will be viewed on is own, as well as rendered from other templates try this:

if ($page->url == $_SERVER["REQUEST_URI"]) include("./head.inc");

// template code

if ($page->url == $_SERVER["REQUEST_URI"]) include("./foot.inc");

The head and the foot will be included only if the page is on it's own url.

  • Like 6
Posted

In this case yes, but it's just an example that can be adapted to other ways of building templates.

  • Like 1
Posted

In future versions of ProcessWire, including the current PW 2.3 dev branch, you can also do this:

if(count($options['pageStack'])) {
  // don't include header/footer, etc.
}

$options['pageStack'] is an array of pages that called render(); before the current one. It basically gives a way for a page to discover the context it is being rendered in.

  • Like 9

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.
×
×
  • Create New...