The age old "block in a block" question

Permalink
some times i think my life would be easier if i could just put a block inside a block...

I know its been mentioned around the forums but I want to ask something different.

When you put an editable area inside the view of another block it will output the "add to block" button inside the parent block.

You cant click the "add to block" as its covered by the parents ccm highlighter (on hover).

so my point is:
can we set z-indexes on the highlighters so that we can get to the embedded areas.

I'm expecting people to say its not how c5 works... (i have read the other forum threads) but I hope someone out there can perhaps have a way of hacking it to work?

As I think this is a feature that would allow a lot of my funny C5 ideas / plans to work. :)

chris123uk
 
JohntheFish replied on at Permalink Reply
JohntheFish
With Universal Content Puller you can nest pulled content. Stack inside stack inside pulled area inside stack inside ....

If you use it, just take care not to go recursive (there is some built in protection against recursion).

https://www.concrete5.org/marketplace/addons/universal-content-pulle...
chris123uk replied on at Permalink Reply
chris123uk
hi john.


thanks for sharing.

I was really looking for a code hack.
i just cooked this up:

it moves the block outside of its parent when in edit mode so i can edit it and it doesnt effect it when out of edit mode so it keeps it within its parent block.

<?php $a = new GlobalArea ('Header Nav');  $a->display($c); ?>
<div class="inner-block"> </div>
<script type="text/javascript">
$(".ccm-block div[handle='testing stuff']").wrap("<div class='block-in-a-block1'></div>");
$(".ccm-block .ccm-add-block:contains('testing stuff')").wrap("<div class='block-in-a-block2'></div>");  
var moveit1 = $(".block-in-a-block1").html(); // get the good bit of the block in a block html
var moveit2 = $(".block-in-a-block2").html(); // get the good bit of the block in a block html
$(".block-in-a-block1").remove();     // clean up   
$(".block-in-a-block2").remove();     // clean up           
$(".inner-block").append(moveit1).append(moveit2); // now place the good bits outside the block
</script>


testing stuff is the handle of the block that is inside the other one.

so it just targets this handle and moves it so that i can hover over and get the add to block highlighter.


would be good if i could find a way to keep the blocks inside of each other.. but still be able to hover over them! :)
chris123uk replied on at Permalink Reply
chris123uk
To make it look like its inside it parent still...

perhaps i could get the embedded blocks positions from top and left before i move them and then add this to the inner-block container ... and use some z-indexes...

needs work. :O
chris123uk replied on at Permalink Reply
chris123uk
just fixed a few bugs.

I would like to make this a function that you can pass handles into.
right now the jquery has to be right after the code for the parents block to work.



<?php $a = new GlobalArea ('Header Nav');  $a->display($c); ?>
<div class="inner-block"> </div>
<script type="text/javascript">
window.setInterval(function cleanMyBlocks(){
$(".ccm-block div[handle='testing stuff']").wrap("<div class='block-in-a-block1'></div>");
$(".ccm-block .ccm-add-block:contains('testing stuff')").wrap("<div class='block-in-a-block2'></div>");  
var moveit1 = $(".block-in-a-block1").html(); // get the good bit of the block in a block html
var moveit2 = $(".block-in-a-block2").html(); // get the good bit of the block in a block html
$(".block-in-a-block1").remove();     // clean up   
$(".block-in-a-block2").remove();     // clean up           
$(".inner-block").append(moveit1).append(moveit2); // now place the good bits outside the block
  $('.inner-block div[id]').each(function (i) {
      var ids = $('[id="' + this.id + '"]');
      if (ids.length > 1) $('[id="' + this.id + '"]:gt(0)').remove();
  });
JohntheFish replied on at Permalink Reply
JohntheFish
Neat. It depends very much on your code getting in there before the block edit code superimposes itself on the block. It may be worth seeing if there are any c5 php events that fire during the preparation for area/block editing that you could use to inject the script.

Another trick I have used in the past is to put a wrapper round a core script function. Most core functions are in the global namespace, so are easily wrapped and subverted. That may provide an alternative way of breaking in and making your code more robust.

http://www.concrete5.org/documentation/how-tos/developers/subvert-t...

There is also an Automatic Block Identification addon that may provide some ideas how to hook in.

http://www.concrete5.org/marketplace/addons/automatic-block-identif...