Jump to content

Integrating PAGEGRID to site with custom theme


Entil`zha
 Share

Recommended Posts

Hi,

First of all, great work @jploch!

I'm testing pagegrid to integrate it to site with custom theme. By custom theme I mean that the site's appearance is already built manually. So I would like to use PAGEGRID to give users an easy way to handle content in the page.

I've now installed PAGEGRID and configured it. But the problem is that when I edit the page with PAGEGRID it also load the manually built appearance. The page is built using append and prepend files.

Any ideas how to do this correctly?

  • Like 1
Link to comment
Share on other sites

@Entil`zha Hi. By default PAGEGRID renders the whole template inside the backend/fontend. But you can easily customize that.

<?php 
if(!$pagegrid->isBackend() ) { 
  // render things only for the frontend
  // Eg. Header, Sidebar
}

// render pagegrid
$pagegrid->styles($page);
$pagegrid->renderGrid($page);
?>

If you are using markup regions you can have the check from above inside your _main.php file.

 

To quickly disable ProcessWire’s automatic append/prepend of file “_init.php” and “_main.php” for a template, you can put this function at the top of your template file.

$pagegrid->noAppendFile($page);

Note that this will disable the append and prepend files from this template also for the frontend. You can also do it the other way around and disable it globally by uncommenting the lines $config->prependTemplateFile and $config->appendTemplateFile in the config.php file off your site folder and include the files manually on the templates where you want them..

  • Like 2
Link to comment
Share on other sites

Hi,

And thx for a quick reply.

I've manage to accomplish what I wanted with following code:

<?php namespace ProcessWire;

if( $pagegrid->isBackend() ) { 
// render things only for the backend
    $content = "";
    $content .= $pagegrid->styles($page);
} else {
	// render things only for the frontend
	$content = "";
}

$content .= "Example content";

if( $pagegrid->isBackend() ) { 
    // render things only for the backend
    $content .= $pagegrid->scripts($page);
    echo $content;
    die;
}

Thank @jploch for pointing me to right direction :)

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

As an alternative you can also do this at the top of your template file (assuming you use your own template file instead of the default pagegrid-page.php):

<?php namespace ProcessWire;

// in the backend we render the default template and return (renders just the field)
if( $pagegrid->isBackend() ) { 
	include('pagegrid-page.php');
	return;
}

//render PAGEGRID and stuff for the frontend
$content = '<p>Some example content for the frontend</p>';
$content .= $pagegrid->styles($page);
$content .= $pagegrid->renderGrid($page);
$content .= $pagegrid->scripts($page);
echo $content;

In this case your page will load two different templates for the backend and the frontend. So you have to load your custom CSS code in both files if you want the backend/frontend to look the same.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...