Editing reusable blocks from scrapbook in dashboard addon-menu?
Permalink
Hey c5-Folks!
I'm just starting to develop with c5 and I didn't find exact information here in the forum nor in the developer documentation.
I want to build something like a howto-module. I found some nice examples which did almost the same what i want, e.g.:
http://www.concrete5.org/marketplace/addons/blogga/...
The administration of this should happen in the dashboard like the blogga addon. My question is the following:
Can I edit the blocks from a global scrapbook in my specific dashboard menu, so that the user must not switch to the scrapbook? It's just to make things more simpler to edit and use.
Thanks in advance!
I'm just starting to develop with c5 and I didn't find exact information here in the forum nor in the developer documentation.
I want to build something like a howto-module. I found some nice examples which did almost the same what i want, e.g.:
http://www.concrete5.org/marketplace/addons/blogga/...
The administration of this should happen in the dashboard like the blogga addon. My question is the following:
Can I edit the blocks from a global scrapbook in my specific dashboard menu, so that the user must not switch to the scrapbook? It's just to make things more simpler to edit and use.
Thanks in advance!
Maybe my explanation was a little bit unclear. I used the same tutorial which you suggested for my first coding prototype. Please forget my first explanation of the problem, because I changed some concepts.
I'm "struggling" with the following:
The goal is to have a guide management add-on which can achieve basically something like ifixit or another tutorial page (example:http://www.ifixit.com/Guide/Installing-iPhone-3G-Battery/577/1... )
I have collections of guides (so to speak categories). under these categories there are products (like laptop/ mp3 player / etc.) and under the products there are various guides (like switching the battery and so on). The collections and products are pages and subpages in concrete5. My problem is to achieve the steps of an guide with reusable blocks.
My first (and actual) Idea is to develop a custom block (step-block e.g.) which can be added to a guide and be reused by the global scrapbook. Now I don't know if it's possible to dynamically determine which actual step (1,2,3...) the step-block has on a certain guide-page? Is this possible? And how do I add this information to the block while rendering? I know that I can get all blocks from the current page $p->getBlogs('Main')), but how do I render (->display()) them so that they are still editable in the area when I'm in edit mode?
Cheers,
Matthias
I'm "struggling" with the following:
The goal is to have a guide management add-on which can achieve basically something like ifixit or another tutorial page (example:http://www.ifixit.com/Guide/Installing-iPhone-3G-Battery/577/1... )
I have collections of guides (so to speak categories). under these categories there are products (like laptop/ mp3 player / etc.) and under the products there are various guides (like switching the battery and so on). The collections and products are pages and subpages in concrete5. My problem is to achieve the steps of an guide with reusable blocks.
My first (and actual) Idea is to develop a custom block (step-block e.g.) which can be added to a guide and be reused by the global scrapbook. Now I don't know if it's possible to dynamically determine which actual step (1,2,3...) the step-block has on a certain guide-page? Is this possible? And how do I add this information to the block while rendering? I know that I can get all blocks from the current page $p->getBlogs('Main')), but how do I render (->display()) them so that they are still editable in the area when I'm in edit mode?
Cheers,
Matthias
Why do you want to re-use a step block on multiple pages (which is the purpose of the scrapbook) -- wouldn't the steps for every product be different?
There are some steps which should be reused on various mobile phones for example. These are steps like opening the case of an iphone which are necessary for multiple guides.
In the meantime I found a similiar solution for this problem provided by the tcslider (http://www.concrete5.org/marketplace/addons/tcslider/... ). This takes away some of the beauty of in-context-editing in my opinion, because my main goal was to show the steps as blocks on the page and make them editable directly, but I still don't know how to combine the "step number"-feature with global scrapbook blocks.
I attached an image to make my goal more clear.
I think the solution on a single page would look similiar to that:
How can I implement this code so that the blocks are still editable in edit mode?
Thanks for your support so far!
In the meantime I found a similiar solution for this problem provided by the tcslider (http://www.concrete5.org/marketplace/addons/tcslider/... ). This takes away some of the beauty of in-context-editing in my opinion, because my main goal was to show the steps as blocks on the page and make them editable directly, but I still don't know how to combine the "step number"-feature with global scrapbook blocks.
I attached an image to make my goal more clear.
I think the solution on a single page would look similiar to that:
$p = Page::getCurrentPage(); $blocks = $p->getBlocks('Main'); $step = 1; foreach($blocks as $b){ echo "<div class="step">Step ".$step."</div>"; $b->display(); } // 2DO: how to display the editable area?
How can I implement this code so that the blocks are still editable in edit mode?
Thanks for your support so far!
Okay, some progress:
my single page:
Can this be improved so that I see the "echo '<h1>Step.'" also in the edit mode? (Would be much nicer for the user)
[ I attached 2 screenshots ]
my single page:
$a = new Area('Main'); if ($c->isEditMode()){ $a->display($c); } else{ $b = Block::getByID($bID); $p = Page::getCurrentPage(); $blocks = $p->getBlocks('Main'); $i = 0; foreach($blocks as $block) { // 2DO: check if block is a step block $i++; echo "<h1>Step ".$i."</h1>"; $block->display();
Viewing 15 lines of 17 lines. View entire code block.
Can this be improved so that I see the "echo '<h1>Step.'" also in the edit mode? (Would be much nicer for the user)
[ I attached 2 screenshots ]
Sounds like the main problem you're trying to solve is outputting incremental numbers for the steps.
As you've seen, the controls for editing blocks is tied up in the "Area" stuff, so if you output a block on its own (outside of the "Area" code), then you don't get the editing controls. (And of course if you output it within the area, you don't get any chance to do things on a per-block basis).
So I'm not sure how to achieve this within the framework of C5, but you might want to use javascript instead -- have it iterate through some kind of wrapper div that surrounds each step and put the number in. Not a perfect solution, but all I can think of.
If you choose to go the javascript route, you can make it easier by automatically outputting a wrapper div around each block like so:
As you've seen, the controls for editing blocks is tied up in the "Area" stuff, so if you output a block on its own (outside of the "Area" code), then you don't get the editing controls. (And of course if you output it within the area, you don't get any chance to do things on a per-block basis).
So I'm not sure how to achieve this within the framework of C5, but you might want to use javascript instead -- have it iterate through some kind of wrapper div that surrounds each step and put the number in. Not a perfect solution, but all I can think of.
If you choose to go the javascript route, you can make it easier by automatically outputting a wrapper div around each block like so:
<?php $a = new Area('Main'); $a->setBlockWrapperStart('<div class="step">'); $a->setBlockWrapperEnd('</div>'); $a->display($c); ?>
Also, did you see this how-to:http://www.concrete5.org/documentation/how-tos/developers/build-a-s...
(looks like it's similar to what you want to do)