Help needed with template conditions workflow

Maybe I’m missing something, but is there no way to have a basic “page” template that gets applied if it’s not a custom page created in bricks?

Example…

Building a client site with some more complex pages we’re designing in bricks, and then they’ll have the ability to create additional simple pages using the classic editor (not gutenberg). I set up a simple header / content / footer “single” template in templates and assigned it to Pages post type. That then blanked out all of my existing bricks-created pages since it was applying the “page” template.

The workaround is manually excluding all of the existing bricks pages one by one, but that’s a maintenance headache and definitely not and ideal and scalable workflow.

What am I missing here?

Thanks

I personally think it’s a weird fudge… but general advice is to add BOTH content blocks to the template.
Add POST CONTENT → Source → Wordpress

Add AT ROOT LEVEL - under this - POST CONTENT → SOURCE → BRICKS

It will populate from whichever is used. I don’t like it, because you could have a client ‘classic edit’ a BRICKS page, add their stuff to classic, and then it renders both.

I’m a little baffled as to why this fundamental feature is so ham-fisted in an otherwise exceptional product. I absolutely agree there should be a simple selector in the page editor to say ‘this template’.

My solution is to force people to use Bricks for pages, but lock the editor down a bit. Bricksforge is good for this - I use AdvancedThemer, because 99% of my clients don’t edit their own pages - only posts - so ‘blanket lock down’ is sufficient.

1 Like

Interesting… So what is your reason for needing a default page? I would think a blank page would be fine, since your clients will be starting from scratch in Gutenberg anyway, right? Or are you thinking that you would create a template in Bricks, which is then converted into Gutenberg content, and which works as the starting point for your clients’ pages. I’m just trying to understand your situation better.

Also, please note that you don’t usually want to create the header and footer as a “Single” template type, if that is what you meant you are doing.

I agree that templates shouldn’t overwrite explicit content, such as page content, when they overlap. That doesn’t seem intuitive. This default behavior should either be changed, or a new setting should be created to implement this, in my opinion. Someone will need to submit it as a feature request, though.

You could use Bricks Builder for the advanced pages and use Gutenberg (or Classic Editor, whichever) for the rest. There is no way to use both for a page at the moment. However, please note that you can use Bricks templates to create a global header and footer, blog archive page, search page, etc, and then have any page you like created in Gutenberg/Classic Editor for easier editing. I am torn between forcing clients to use Bricks or forcing them to use Gutenberg myself right now. I’ve chosen the option I’ve outlined above.

Thanks, that helps to better understand the flow, but not quite a a solution to my issue. Let me try to better explain with some examples. The goal is to keep the client out of Bricks, just using the classic (no Gutenberg) for posts and a few simple page needs that come up.

This is a page designed in Bricks that I’ll update (in Bricks) when needed, no client editing.

This is an example of a random page the client created, obviously a mess because there’s no template assigned to it right now.

To fix that, I create a new single template named “Page”, add a padded section with inner container and then WP Post Content. Set conditions to post type = page. That fixes the Know Your Rights page, but then all other bricks pages are blank since they match the condition. To fix THAT, I have to add a condition to exclude all of the bricks designed pages. I need a condition for “use this template for any random classic editor pages the client makes.”

I tried the approach mentioned above about adding 2 post content elements, one for WP data one for Bricks data. That sort of works, but to style things properly I need to put the WP post content in a padded section, so that gets rendered either way, adding dead space to the page.

It’s very strange to me this isn’t built in, seems like it would be a common need.

I see what you mean. Thanks for the links. In this case the only thing I can think of (besides using the Post Content element that @digismith mentioned above) is to use CSS to style the HTML on the page. Here’s how.

Go to Bricks > Settings > Custom Code. Enter the below into the Custom CSS field.

article {
    margin-top: 8em;
    [Anything Else Needed]
}

This CSS, entered here, will be included on every page on your website. As you probably don’t use the article element when working in Bricks, this will only target WordPress-generated content on the website, as WordPress loves to wrap content with this tag.

I’ve added a more detailed solution with more variations that may help solve this problem in a blog post I’m linking to below.

Thanks for bringing this up! It’s helped me to think through this problem more.

Made a feature request topic that hopefully would resolve your issue. Please weigh in there too if possible.

Ah, I understand now. By Post Content, you mean the Post Content Bricks element.

This didn’t click before, I don’t know why.

Just as an addition to what you’ve already said, I’ve just found this tutorial online. He uses the has_blocks WordPress function (starting at the 8 minute mark).

But yes, if the client decides to add Page Editor content, it will be added onto the Bricks Builder page content.

Thanks, unfortunately we’re stuck with classic editor (they hate G), and a broader has_content check also returns true for bricks content. That gets me close enough though, for this case I’ll just add an ACF toggle for classic/bricks and check against that in conditional. Really appreciate you following up!

Hi,

I think in template settings, we need a condition to render template only if there is not bricks data.

Like it is done in bricks code:

<?php
get_header();

$bricks_data = Bricks\Helpers::get_bricks_data( get_the_ID(), 'content' );

if ( $bricks_data ) {
	Bricks\Frontend::render_content( $bricks_data );
} else {
	if ( have_posts() ) :
		while ( have_posts() ) :
			the_post();
			get_template_part( 'template-parts/page' );
		endwhile;
	endif;
}

get_footer();

My solution (but i think we need better) is to add:

<?php echo do_shortcode( '[bricks_template id="136"]' ); ?>

in a file wp-content/themes/bricks-child/template-parts/page.php

1 Like