Change layout based on page

Hi there,

Is there a way to switch overall page layout based on the page identity? Ideally, I’d like to assign layouts to pages. Incidentally, how do I identify which page is loaded in code?

Thanks!

Simon

In the view for a page you have access to the page object, so you could check its ID or slug or title to figure out which page you’re showing and make some changes that way. You could call out to another view or just otherwise make changes based on that to have different “layouts.”

You could also change the actual Laminas view layout to make more major changes. Most themes only use a single layout but if you wanted to make changes to the outer “frame” of the page for a single page or view, you can do that.

We also have a somewhat related small feature slated for later release, that will add a class to the page body tag based on the slug, to make it easier to do page-specific changes in pure CSS.

2 Likes

Hi, thanks for this!

I’d like to access the page ‘label’ from the template. I have a navigation page and would like to display the label as the title rather than ‘Items’ .

Thanks!

This topic was automatically closed 250 days after the last reply. New replies are no longer allowed.