$this->action('like') in add.php

Permalink
Hi,

Is it possible to ask a block's controller action from the add.php ?
I want to use ajax without use package tools..

thanks in advance

Seb

sebastienj
 
jordanlev replied on at Permalink Reply
jordanlev
I don't think it's possible (but you already know what I think :)
ScottC replied on at Permalink Reply
ScottC
you can also reference blockToolsUrl

if you look at the page_list block you'll see the code
public function getRssUrl($b){
         $uh = Loader::helper('concrete/urls');
         if(!$b) return '';
         $btID = $b->getBlockTypeID();
         $bt = BlockType::getByID($btID);
//omitted code
         $rssUrl = $uh->getBlockTypeToolsURL($bt)."/rss?"//extra stuff deleted
         return $rssUrl;
      }


so you can in fact do ajax from an add or edit, if you wanted to do this while sharing the block's controller method you'd have to get an instance of that block then get its controller then call the controller's function from your tools request.
jordanlev replied on at Permalink Reply
jordanlev
Ahh... I see -- so you still have that extra file in the tools directory but it's just a placeholder of sorts that redirects the request to the controller's method. Interesting.
ScottC replied on at Permalink Reply
ScottC
yeah it stays modular of sorts since it is with the block and not part of a package tools file, it is just something that can be requested that passes through the dispatcher so you can load up an instance of the block and through a few methods(which i can't remember off the top of my head).

You can actually get an instance of that block's controller populated by the db row record and any method then called in the controller will return the standard data.

you could do a bID=55&method=get_price or who knows what, calling the method if it exists on the controller and having json returned.

That's just one way, but the rss part of page_list helps you out a lot, it is one of the really great example blocks IMO.