Jump to content

RockFrontend – Using autoload-layout and template-specific latte-files


nurkka
 Share

Recommended Posts

Hi @bernhard, I really like to work with RockFrontend (and RockPageBuilder)!

Now I have some questions resp. want to make sure what would be the best practice:

I am using the autoload-layout feature and am loading a _layout.latte file. But I also would want to make some template specific modifications, like having an element on the startpage, which is not included on all the other pages. I can add this element in home.php, but then it will be included before the opening <html>-tag. When I put the elements into home.latte, this file won't be output until I add the {do $rockfrontend->noLayoutFile = true} directive to it. But if I add this line, the home.latte will of course override my _layout.latte, which is also not what I want.

So I added the following to my _layout.latte:

	...
	{* only on the startpage *}
    {if $page->id==1}
    	{include "src/latte/partials/custom-element.latte"}
	{/if}
</body>
</html>

- Is this currently a recommended way to e.g. have a custom element on the startpage?

- I noticed that content in home.php will always be added to the output, while home.latte will only be added, when using {do $rockfrontend->noLayoutFile = true} in it. Is it possible to load home.latte while preserving _layout.latte, too?

- Is RockFrontend compatible with ProcessWire's MarkupRegions?
=> I removed _main.latte and am now rendering the template-specific latte-files "manually". With "echo" in the respective template PHP-files, and using a _output.php, ProcessWire's markup regions work. But I think one cannot use both techniques, _main.latte and Markup Regions, at the same time. Also, _rockfrontend.php has to be deactivated.*

- Currently the page in the docs regarding the render()-method is empty. https://www.baumrock.com/en/processwire/modules/rockfrontend/docs/render/

- Is it possible to render any latte-file with render()? Then I could render home.latte within home.php ... but I would again need MarkupRegions to insert the rendered markup in the right place. I tried it, but with no luck so far.
=> RockFrontend's render() method can render any latte-file. The trick is to omit _main.latte and implement a more "traditional" approach, with a custom _output.php, in which the Markup Regions are put together.*

Maybe you have any clues ... and what method would you use to insert template specific markup while using a global _layout.latte template?

* Of course, the purpose of RockFrontend is not to only use the render()-method, so I recommend to not use Markup Regions and use the full feature set of RockFrontend instead.
Also, it could be that I have overlooked something, so this information may be subject to change.

Edit: Answered some of the questions

  • Like 1
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...