Block with Areas or SubBlocks?

Permalink 1 user found helpful
Hello, iam new with Concrete5 and this CMS is interesting, but i have question.

I have one basic template with 2 areas (sidebar and main). Now iam developing small block, which should have Title and Area (in best case) for adding subblocks.

Just some hierarchy block nesting.

Is this possible?

For example:
MainArea
--- My Block (Title)
------- Content
------- Video
------- Etc.

Thanks for reply.

View Replies: View Best Answer
cannonf700 replied on at Permalink Reply
cannonf700
Well, what have you tried?
I would use the "content" block for both the Title and the Content. use the style's drop down menu to choose a Header Tag for the title and then just start typing your content.

Then, depending on the source of your video you could add the Vimeo block, YouTube block, the Video Block or use the HTML block to paste code from your video's host site.

just keep going in this manner, adding blocks underneath each other.
DjOggy replied on at Permalink Reply
Hi,

so i have tried this:

<div>
   <h2><?php echo $title?></h2>
   <hr />
   <?php 
      $as = new Area('BlockInside');
      $as->display($c);
   ?>   
</div>


This doesnt work.

I know, i could use blocks one by one, but i have this situation.

I want prepare some styled blocks (like boxes with various content) with concrete hardcoded things (like that title) and with some editable things (like content or similar).

Here you can see, what i mean exactly
http://www.dannyk.cz/files/example.png


As you can see, i have two boxes of same type, but with different content. A this is where my Areas in Blocks idea comes from.
jordanlev replied on at Permalink Reply
jordanlev
I have had this problem with my themes as well. There is no perfect solution unfortunately.

First of all, in your code above, the "echo $title" isn't going to work -- there is no such variable available to your template (unless you created it yourself in the controller, but that is a rare thing to do so I'm assuming not).

What is this title, by the way? Is it the title of the page, or the title of the block, or just the title of that section of the page? If it's the same title on every page, just put that title into your HTML (just plain old html, not a php echo). If it's different on every page, then you might want to create separate areas for each title and body (but this only works if you have a set number of sections on the page -- it won't work if the user can add as many sections as they want, because there won't be enough areas then).

The best solution is probably to do as @cannonf700 suggests, and create a style in your CSS that can be applied to an h2 or h3, and tell your users to add the title and set h2 or h3 in the content block for each section. To make this work, you'd want to change your code above to something like this:
<div class="main-block-container">
    <?php
    $a = new Area('Main');
    $a->display($c);
    ?>
</div>

Then in your CSS, have something like this:
div.main-block-container h2 {
  /* title styles here */
}


Now you just have to instruct your client to put in some h2 content at the top of each section.

Hope that helps!

-Jordan
DjOggy replied on at Permalink Reply
Hi and thx fo reply.

I used for this basic_test block, which is in tutorial on this site. Title variable is set by add.php and edit.php (is defined in db.xml). That title in example is title of box block. On the screen are box blocks in sidebar. This is what i trying :(
Mnkras replied on at Permalink Reply
Mnkras
you can make a custom template...
DjOggy replied on at Permalink Reply
Thanks, i look at that.
jordanlev replied on at Permalink Best Answer Reply
jordanlev
Okay, I see what you're saying now (I think). So, you cannot combine Areas inside Blocks -- Areas go in your theme's page type templates, and Block display code goes in Block view.php files.

So if you're trying to create a block that outputs the title and then some content, you want to leave that code you have for the Area in the page type template (like default.php, left_sidebar.php, full.php, whatever). Then in you block's view.php file you put the <?php echo $title; ?>

Then it's up to the user of your site to place that block inside that area.

Does that make sense?
DjOggy replied on at Permalink Reply
Thanks, it is not exactly what i went, but as i see, its only possible solution (maybe that custom templates will work).

Thanks to all for advices.
RadiantWeb replied on at Permalink Reply
RadiantWeb
you can create an area generated dynamically from a block.

you do this in the view layer.

you have to add editmode checks, and insert a close out of the editable area the block happens to be in, and then the same for closing it out.

Something to the effect of this:

global $c;
if($c->isEditMode()){
  echo '</div>';
}
$a = new Area('temp_area');
$a->display($c);
if($c->isEditMode()){
  echo '<div>';
}


I have done this. it gets a bit buggy with layouts, but if I understand you correctly...this is what you were asking for.

Chad
DjOggy replied on at Permalink Reply
Hi, thx for reply.

This solution looks very interesting. I will try that. Thx
Nomoreglitches replied on at Permalink Reply
Nomoreglitches
Hello Chad,

although after 3 years, i am trying to use your code to create a block which contains an area where one can add sub-blocks. I get to see the area in the block, however in edit mode the highlighting is such that I can never click on the area inside the block in order to add a sub-block. Did you have a similar issue? How did you resolve it?

Thanks,
Konstantinos
pvrs2006 replied on at Permalink Reply
Hai Guys,

hope you are good.

I being using to for 2 days the is a awesome cms and I'm trying to integrate my html responsive template to concentrate 5 cms during this migration i have couple of questions below
1. I need to add sub blocks with in main block section?
2, I'm trying to integrate customized flexslider module/addon I dont get proper steps to implement.
3. Same way I need to integrate customized thumbnail carousal gallery
4. I could not find any addon for newsletter functionality (like subscription, approve subscriber, creating/editing the newsletter, send newsletter ect)
pvrs2006 replied on at Permalink Reply
This is most urgent work because we are already running out of deadline please help me to proceed further
jordanlev replied on at Permalink Reply
jordanlev
For "sub-blocks", custom sliders and carousels, I have an addon called "Designer Content Pro" that is made to handle these situations:http://concrete5.org/marketplace/addons/designer-content-pro...

For newsletters, you're best off using something like MailChimp. Sending bulk emails from your own server will result in poor deliverability due to spam filters. That being said, if you insist on doing it from the website itself, there is an addon for it here:http://www.concrete5.org/marketplace/addons/mailing-list/...

Good luck!

-Jordan

> On Sep 10, 2014, at 6:11 AM, concrete5 Community <[email protected]> wrote: