Open add-on direct instead of add block menu?

Permalink
is it possible to open an add-on direct instead of the add block menu?

something like this?

<?php
$a = new Area('Youtube');
$a->display($c[youtube video]); <--- the add-on's name?
?>

 
pvernaglia replied on at Permalink Reply
pvernaglia
Sometimes you can, sometimes you can't. It usually depends if the block has any javascript associated with it. There is a discussion here about adding the pagelist block programmatically:http://www.concrete5.org/community/forums/customizing_c5/embed-page...

You can put the block in the scrapbook and code that in the theme, that always works:

[code}
<?php
$block = Block::getByName('BLOCK NAME');
if( is_object($block) ) $block->display();
?>
(www.weblicating.com/c5/cheat-sheet/)
[/code]
SirFlomme replied on at Permalink Reply
thank you.

I will try that and give feed back on it.

I will mark your answer as best if it works :)
SirFlomme replied on at Permalink Reply
can you help me with this code?

<?php
$b = Block::getByName('recent_tweets'); <--- the folder name of the package?
$bv = new BlockView();
echo  $bv->render($b, 'edit'); <-- "edit/view" is the name of what file in the package it should open?
?>


so if i get it right it should open the edit menu?

but the button wont show
SirFlomme replied on at Permalink Reply
any?
Mainio replied on at Permalink Reply
Mainio
Hi,

If you use this solution, you should use the __Scrapbook Block Name__ as the block identifier:
$b = Block::getByName('ScrapbookBlockName'); // <--- Scarpbook Block Name
$bv = new BlockView();
echo  $bv->render($b, 'view'); // <-- the view name for your block, e.g. if you want to use custom template use 'templates/my_template'


And you should add a new "Recent Tweets" Block to your Scrapbook. Just go to Dashboard => Scrapbook => Global => "Add Block to Scrapbook"

After adding it, just rename it to ScrapbookBlockName (or whatever you want to use) by clicking the newly created block's name.

This way it should pull the block from scrapbook.

Antti / Mainio
SirFlomme replied on at Permalink Reply
what i want to do is when you normaly open up the "add block menu" i will skip that and add a pre selected block, så i still get the edit menu so i can fill in that :)
Mainio replied on at Permalink Reply
Mainio
Ok, not getting at all what you want.

Maybe a screenshot/mockup of what you're trying to accomplish would help...? Or someone who understands better.

Antti
SirFlomme replied on at Permalink Reply
i want it to do like this :)

http://i42.tinypic.com/2mocakn.png...
Mainio replied on at Permalink Best Answer Reply
Mainio
Ok, that requires you to override some JS, it's quite a biggie and requires quite good knowledge of JavaScript.

For a free advice I can give you that you need to override this function:
var _ccm_showAreaMenu = ccm_showAreaMenu;
ccm_showAreaMenu = function(obj, e) {
   var yourOverrideCondition = false;
   // TODO: Your override condition checking here
   if (yourOverrideCondition) {
      // TODO: Your override here
   } else {
      // If not override, call the original function
      _ccm_showAreaMenu();
   }
}


You can find that functions original version from /concrete/js/ccm.ui.js.

In the code is commented what you need to do.


Antti / Mainio
SirFlomme replied on at Permalink Reply
thank you i tried to find that, in the php files the hole day, but did'nt knew i should look in the js