Determining if page is in edit mode from page_theme.php


I would like to know if I can check if the page is in edit mode before setting the grid framework.

Something from the page_theme like:
if ($c->isEditMode) {
  pThemeGridFrameworkHandle = 'bootstrap';
} else {
  pThemeGridFrameworkHandle = 'foundation';
I'm just trying to get the "edit grid layout" functionality to work alongside a flex based column framework like Foundation6.

View Replies: View Best Answer
JohntheFish replied on at Permalink Reply
Yes, the usual way.

See /concrete/elements/header_required.php for examples of using it early in the page rendering process.
MrKDilkington replied on at Permalink Best Answer Reply 1 Attachment
Hi ob7dev,

Since $pThemeGridFrameworkHandle is protected, I added a method in page_theme.php to change it.
public function setGridFrameworkHandle($pThemeGridFrameworkHandle)
    $this->pThemeGridFrameworkHandle = $pThemeGridFrameworkHandle;

You then have to override the Core Area Layout block controller to conditionally switch grid frameworks.

I have attached the override controller as an attachment. The added code is enclosed in "CHANGES" and "END CHANGES" comments.
ob7dev replied on at Permalink Reply
@JtF, would it be OK to override the core area layout block controller like this in a marketplace theme???

@MrK, thanks for putting that together.

I think I will try creating a method in page_theme that sets the framework like you did MrK but call it from the header like John suggested instead of overriding the core block controller...

The question is, how do I call a public function declared inside page_theme from the themes template files?
is using:
use Concrete\Package\MyPackage\Theme\MyTheme\PageTheme as PageTheme;
from a page_template OK????
MrKDilkington replied on at Permalink Reply

I don't believe just changing the grid framework handle is enough. That is what I first tried and it only changes the block grid framework, not the custom layout grid framework.

Only the Core Area Layout block override appeared to change the custom layout grid framework.

Based on your experience with it and getting a flexbox based grid framework to work, this might be something to be added to the core.
ob7dev replied on at Permalink Reply
Until then I guess it's CSS hacks!
JohntheFish replied on at Permalink Reply
Overriding a core class usually dictates a package is black/bleeding edge. If its done in a very localised and well defended way, it may have a case for being red, but I doubt if that could be justified in this case.

I don't know if its possible, but as you are developing a theme you have control of how pages are generated within that theme, so you may be able to wrap/extend core functionality rather than override it.

As your primary reason is for swapping grid frameworks depending on context, perhaps you could attack the problem from the other end, create a new grid framework and do the switching within it.

Having said all that, there are foundation based themes in the marketplace where the foundation css is scoped to just the front end of the site and do not interfere with the core or editing. So there are likely solutions that don't involve the convolutions you are considering.