Jump to content

[solved] Do everything go in the blocks or can you use Processwire basic template logic mixed with blocks?


Atlasfreeman
 Share

Recommended Posts

When working with the rock page builder if i know i want some markup untouched such as i want to do a array  finding all children and putting and image, can i do this on a "template" as i normal would in ProcessWire or du i need to do it in the block? If doing it in the block the enduser could move it around (not a big problem for the case i am working ATM). But im quorious should everything go in the blocks now?

Edited by Atlasfreeman
  • Like 1
Link to comment
Share on other sites

Hey @Atlasfreeman thank you for that question!

That's totally up to you ? RockPageBuilder gives you the freedom to define different types of content elements that the end user can place on the page in any order.

On 11/28/2023 at 12:50 PM, Atlasfreeman said:

such as i want to do a array  finding all children and putting and image, can i do this on a "template" as i normal would in ProcessWire or du i need to do it in the block?

I'm not sure I understand? Do you mean a listing of child pages? Like on a blog overview page that lists all children (aka blog posts) and shows a preview image for every post?

If that is what you are asking then there are two possible solutions:

1) Create and use a block to list children

This approach is more flexible but might need some training for the client to understand the concept. The benefit is that you can add content on top of that page listing or below. You have a lot of freedom. You could even add block settings, for example a setting of how many blog posts should be shown. For the blog overview page you might choose 12.

One benefit of this approach is that you can reuse this blog on other pages. For example you could add the same block on the frontpage but only show 3 blog posts. You could then add another setting (checkbox) to show pagination or not. For the frontpage you'd hide pagination, for the blog overview page you'd show pagination.

2) Create and use a dedicated template

That approach is less flexible but easier for the end user as it has less options and less freedom.

----

I tend to go with option 1. It's really not hard to do and it's also easy to understand for most of my clients.

Does that help?

Link to comment
Share on other sites

Normally i would do a page where all "children" or specific template where found to give the viewer and overview of what they can click on (im often doing portfolio websites).
Then the end-user only need to do new "under pages", and their new project will automatic come on the front page (I think that is nice, and a feature i love about processwire)
I find the block system very intuitive and have made it with this now. Maybe you could make a lock block feature one day in the future.

Anyway, you are talking about how to create reuse of blocks and how they can have variation we also see this in the demo, and i can see it in the prebuilt block, tought i never used .latte is there anywhere you can direct me to how you do this in php, is there any guide for this?

I think your variations are this in the .latte files (or a part/start of it):

{var $maxw = "maxw-".$block->settings('maxw')}
{var $width = $block->thumbWidth()}

Link to comment
Share on other sites

Hey @Atlasfreeman there's really no difference in using block settings in latte or php files. Only the syntax is a little different of course.

In latte you write {$block->settings('foo')} which would be <?= $block->settings('foo') ?> in PHP.

52 minutes ago, Atlasfreeman said:

Normally i would do a page where all "children" or specific template where found to give the viewer and overview of what they can click on (im often doing portfolio websites).

Yeah, that might be a good use case for sticking with the good old approach of dedicated templates. You can still use the RockPageBuilder blocks field on that template, so you will save a lot of time nevertheless ? 

54 minutes ago, Atlasfreeman said:

I find the block system very intuitive and have made it with this now. Maybe you could make a lock block feature one day in the future.

What do you mean by lock block? A block that is only editable by userusers?

Link to comment
Share on other sites

  • 8 months later...

I still have a problem whenever I use the /site/template/file.php in this case (index_filter.php)

I want to do a page that catches all the page references. And I don't want to use the block on this specific page.
Is there something I'm missing? Why will it not show the code?

Code look like this:

<?php
 
echo "<h1>yolo</h1>";
 
echo "<div class='archive_wrapper'>";
$link = $pages->find("pagereference=$page, sort=parent.sort, sort=sort");
 
foreach ($link as $content){
echo "<div class='content_link'>";
echo "<div class='content_link_wrap'>";
 
if ($content->cover_img) {
echo "<a href='{$content->url}'><img class='maxheight' src='{$content->cover_img->url}' alt='{$content->cover_img->description}'></a>";
}
 
echo "<a class='ttle' href='{$content->url}'><h2 class='content_text'>{$content->title}</h2></a>";
 
echo "</div>";
echo "</div>";
 
}
echo "</div>";
 
 
?>
Link to comment
Share on other sites

Hi @Atlasfreeman I'm sorry but I don't understand what you are trying to say.

1 minute ago, Atlasfreeman said:

I still have a problem whenever I use the /site/template/file.php in this case (index_filter.php)

What is file.php? What is index_filter.php? These things might be obvious for you but they are not for me/us. Every PW project is different, so you have to explain your setup in more detail.

2 minutes ago, Atlasfreeman said:

I want to do a page that catches all the page references.

I don't understand what you mean by "catches all the page references".

3 minutes ago, Atlasfreeman said:

And I don't want to use the block on this specific page.

The RockPageBuilder field is a PW field like any other field. You output it like any other field in PW, see https://www.baumrock.com/en/processwire/modules/rockpagebuilder/docs/blocks/#rendering-blocks

If you don't want to output any blocks on any page, don't add the field to the template and don't add the render call in the template file.

----

Maybe anybody else understands your questions better.

  • Like 1
Link to comment
Share on other sites

  • Atlasfreeman changed the title to [solved] Do everything go in the blocks or can you use Processwire basic template logic mixed with blocks?

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

×
×
  • Create New...