CB autoaction route triggers

1 year 5 months ago #331441 by krileon
Replied by krileon on topic CB autoaction route triggers
Those triggers aren't meant for display. They're meant to be used to rewrite URLs. See the file path provided above for an example of how they're used in a plugin. All you'll have is the information provided by the URL, which in most cases is just going to be the action to perform on the plugin, the function for that action, and if there's an id then also the id. If you need further details you'll have to build out an activity object from the id so yes you'll need to build an ActivityTable object.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

1 year 5 months ago - 1 year 5 months ago #331467 by activha
Replied by activha on topic CB autoaction route triggers
Yes but even building the two functions build and parse are not enough.
Should we write directly a routertrigger file in the Plugin\Activity\Trigger folder like Groupjive ?
Or do we simply need to add a new class to extend cbPluginHandler and CB will do the following ?
Can you precise how to include the functions that we wrote ?

The functions are :
function ActivationBuildRoute($query)
{



        $app        = JFactory::getApplication(); 
        $menu        = $app->getMenu();


        if (empty($query['Itemid']) || $query['option']!="com_comprofiler" || $query['view']!="pluginclass" || $query['plugin']!="cbactivity" || $query['action']!="activity"  || $query['id']!="" )
        {
            return;
        }
        

        $app        = JFactory::getApplication(); 
        $menu        = $app->getMenu();
        $segments = array();

        unset($query['Itemid']);

        $segments[] = $query['view'];
        unset( $query['view']);
        
        $segments[] = $query['plugin'];
        unset( $query['plugin']);

        $segments[] = $query['action'];
        unset( $query['action']);

        $segments[] = $query['id'];
        unset( $query['id']);

         return $segments;




}

function ActivationParseRoute($segments)
{


     $vars = array();
     $vars['view'] = $segments[0];
     $vars['plugin'] = $segments[1];
     $vars['action'] = $segments[2];
     $vars['id'] = $segments[3];


     return $vars;

}

Please Log in to join the conversation.

1 year 5 months ago #331470 by krileon
Replied by krileon on topic CB autoaction route triggers
CB GroupJive provides a fully functional working example for you. Simply copy it over and implement whatever URL rewriting behavior you need. See the below relevant files.

Custom Routing
components/com_comprofiler/plugin/user/plug_cbgroupjive/library/Trigger/RouterTrigger.php

Binding to Routing Triggers
components/com_comprofiler/plugin/user/plug_cbgroupjive/cbgroupjive.php

Can you precise how to include the functions that we wrote ?

I cannot help you with custom coding without a Business Membership, sorry.

Additionally CB Activity 6.0.0 will have URL rewriting behavior implemented from the start as well.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

1 year 5 months ago #331471 by activha
Replied by activha on topic CB autoaction route triggers

I cannot help you with custom coding without a Business Membership, sorry.

I'd be glad to subscribe but we don't have an answer yet from Beat since our request !

Additionally CB Activity 6.0.0 will have URL rewriting behavior implemented from the start as well

Yes but we need a quick code and anyway we'll need to implement something like menuitem/[var_params_ourowntitlefield]-[var_id] and I doubt that we could do it with CB 6 routing implementation ?

Admit that the documentation for the triggers onparseroute and onbuildroute is rather sparse and as there is no output possible to test, it's rather difficult to move on.

At least tell me if adding something like this is fine or not ? is the third argument the path to the file ?
$_PLUGINS->registerFunction( 'onBuildRoute', 'ActivationBuildRoute', '/ahatools/activations/activation_router.php' );

$_PLUGINS->registerFunction( 'onParseRoute', 'ActivationParseRoute', '/ahatools/activations/activation_router.php' );

class ActivationRouter extends \cbPluginHandler
{
     function ActivationBuildRoute($query)
    {xx}

    function ActivationParseRoute($segments)
    {xx}
}    
 

Please Log in to join the conversation.

1 year 5 months ago #331478 by krileon
Replied by krileon on topic CB autoaction route triggers

 I'd be glad to subscribe but we don't have an answer yet from Beat since our request !

Sorry for the delay. He's working his way through all the requests.

Yes but we need a quick code and anyway we'll need to implement something like menuitem/[var_params_ourowntitlefield]-[var_id] and I doubt that we could do it with CB 6 routing implementation ?

Correct so you would still need custom routing for that.

Admit that the documentation for the triggers onparseroute and onbuildroute is rather sparse and as there is no output possible to test, it's rather difficult to move on.

Your best option is to just directly look at existing usages in plugins.

At least tell me if adding something like this is fine or not ? is the third argument the path to the file ?

No, it's the class. You need to include your file first if you intended to store this externally.
$_PLUGINS->registerFunction( 'TRIGGER', 'FUNCTION', 'CLASS' );


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

1 year 5 months ago #331498 by activha
Replied by activha on topic CB autoaction route triggers
Well, I followed your advice and coded this with an autoaction only acting on the menuitem id with the triggers onparseroute and onbuildroute, but no luck so far...

Any idea of what's wrong (before we get the business subscription active, then you'll deduct from the time :-) )
use CBLib\Language\CBTxt;
use CBLib\Application\Application;
use CB\Plugin\Activity\CBActivity;

$_PLUGINS->registerFunction( 'onBuildRoute', 'build', 'ActivationRouter' );

$_PLUGINS->registerFunction( 'onParseRoute', 'parse', 'ActivationRouter' );

class ActivationRouter extends \cbPluginHandler
{
    public function build( $router, $plugin, &$segments, &$query, &$menuItem )
    {
        if ( ( $plugin !== 'cbactivity' ) || ( ! $query ) || ( ! isset( $query['action'] ) ) ) {
            return;
        }        
        $action[] = $query['action'];        
        unset( $query['action']);
        unset( $query['id']);
        $menuAction                    =    ( $menuItem && isset( $menuItem->query['action'] ) && ( $menuItem->query['action'] !== '' ) ? $menuItem->query['action'] : null );
        $menuId                        =    ( $menuItem && isset( $menuItem->query['id'] ) && ( $menuItem->query['id'] !== '' ) ? (int) $menuItem->query['id'] : null );        
    }

    public function parse( $router, $plugin, $segments, &$vars, $menuItem )
    {
        if ( ( $plugin !== 'cbactivity' ) || ( ! $segments ) ) {
            return;
        }
        $menuAction                                    =    ( $menuItem && isset( $menuItem->query['action'] ) && ( $menuItem->query['action'] !== '' ) ? $menuItem->query['action'] : null );
        $menuId                                        =    ( $menuItem && isset( $menuItem->query['id'] ) && ( $menuItem->query['id'] !== '' ) ? (int) $menuItem->query['id'] : null );
                
         $vars['action'] = 'test';
         $vars['id'] = (int) $segments[0];

    }
}    

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.205 seconds

Facebook Twitter LinkedIn