CB autoaction route triggers

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

Or do you mean they're just copying the URL from browser address bar to share?

Yes unluckily a lot of our business contacts simply use the url to copy paste in an old fashioned way...

So I need to have the single activation with the correct "marketing" url for them.

I wrote this which works fine for building but not for parsing, it I can get it to work that should be fine.
BUILDING
// $plugin = $variables['var2'];
// $segments = $variables['var3'];
// $query = $variables['var4'];
if ( ( $variables['var2'] !== 'cbactivity' ) || ( ! $variables['var4'] ) || ( ! isset( $variables['var4']['action'] ) ) || ($variables['var4']['action'] !== 'activity') ) {
    return;
}

if ( isset( $variables['var4']['func'] ) && ( $variables['var4']['func'] !== 'show' ) ) {
    $variables['var3'][]            =    $variables['var4']['action'];
    unset( $variables['var4']['action'] );
    $variables['var3'][] = $variables['var4']['func'];
    unset( $variables['var4']['func'] );

    if ( isset( $variables['var4']['id'] ) ) {
    //build activity object and retrieve params activ if exists
        $activity = new \CB\Plugin\Activity\Table\ActivityTable();
        $activity->load( (int) $variables['var4']['id'] );
        if ( ! $activity->getInt( 'id', 0 ) ) {
            return;
        }
        $params = $activity->params() ;
        $title =  !empty($params['activ']) ? urlencode(str_replace(' ', '-', strtolower($params['activ'].'-'))) : null;
        $variables['var3'][]    =    $title.$variables['var4']['id'];

        unset( $variables['var4']['id'] );
    }
}
if ( (!( $variables['var4']['func'] ) || ( $variables['var4']['func'] == 'show' ) ) && isset( $variables['var4']['id'] ) ) {    
        //build activity object and retrieve params activ if exists
        $activity = new \CB\Plugin\Activity\Table\ActivityTable();
        $activity->load( (int) $variables['var4']['id'] );
        if ( ! $activity->getInt( 'id', 0 ) ) {
            return;
        }
        //func=show not displayed
        unset( $variables['var4']['action'] );    
        unset( $variables['var4']['func'] );    
        $variables['var3'][] =    null;    
        $params = $activity->params() ;
        //todo : trouver une meilleure fonction pour encoder l'url sans chiffres pour la parser
        $title =  !empty($params['activ']) ? urlencode(str_replace(' ', '-', strtolower($params['activ'].'-'))) : null;
        $variables['var3'][]    =    $title.$variables['var4']['id'];

        unset( $variables['var4']['id'] );
}






PARSING
// $plugin = $variables['var2'];
// $segments = $variables['var3'];
// $vars = $variables['var4'];
if ( ( $variables['var2'] !== 'cbactivity' ) || ( ! $variables['var3'] ) ) {
    return;
}

if ( isset( $variables['var3'][0]) && ($variables['var3'][0] === 'activity')) {
    $variables['var4']['action'] = $variables['var3'][0];

    if ( isset( $variables['var3'][1] ) ) {
        $variables['var4']['func'] = $variables['var3'][1];

        if ( isset( $variables['var3'][2] ) ) {
            $variables['var4']['id'] = $variables['var3'][2];
        }
    }
}

if ( isset( $variables['var3'][0]) && ($variables['var3'][0] !== 'activity')) {
    $variables['var4']['option'] = 'com_comprofiler';
    $variables['var4']['view'] = 'pluginclass';
    $variables['var4']['plugin'] = 'cbactivity';
    $variables['var4']['action'] = 'activity';
    //$variables['var4']['func'] = 'show';
    //todo trouver une meilleure fonction pour récupérer les ids :-)
    $variables['var4']['id'] = preg_replace('/[^0-9]/', '', $variables['var3'][0]);
}

Please Log in to join the conversation.

1 year 5 months ago #331679 by activha
Replied by activha on topic CB autoaction route triggers
I got a message saying that this  forge.joomlapolis.com/issues/9072  was integrated in the new build but can you let me know where to find it ?

Thanks

Please Log in to join the conversation.

1 year 5 months ago #331709 by krileon
Replied by krileon on topic CB autoaction route triggers
It's available now. We had to pull the release initially last week as it had an install bug related to our CSRF switching over to Joomla's instead of our own internal usage. This is now fixed so it has now been released.


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.
The following user(s) said Thank You: activha

Please Log in to join the conversation.

1 year 5 months ago #331717 by activha
Replied by activha on topic CB autoaction route triggers
Ok just installed and tested.
The build autoaction works fine but the parse one fails.
Could it be because there is no main router yet for CB Activity ?

Without the build autoaction the activity is built as /societe/?id=xxx and we rewrite it to /societe/name-of-company-xxx

But the parse does not reverse it with the following code :
// $plugin = $variables['var2'];
// $segments = $variables['var3'];
// $vars = $variables['var4'];
if ( ( $variables['var2'] !== 'cbactivity' ) || ( ! $variables['var3'] ) ) {
    return;
}

if ( isset( $variables['var3'][0]) && ($variables['var3'][0] === 'activity')) {
    $variables['var4']['action'] = $variables['var3'][0];

    if ( isset( $variables['var3'][1] ) ) {
        $variables['var4']['func'] = $variables['var3'][1];

        if ( isset( $variables['var3'][2] ) ) {
            $variables['var4']['id'] = $variables['var3'][2];
        }
    }
}

if ( isset( $variables['var3'][0]) && ($variables['var3'][0] !== 'activity')) {
    $variables['var4']['option'] = 'com_comprofiler';
    $variables['var4']['view'] = 'pluginclass';
    $variables['var4']['plugin'] = 'cbactivity';
    $variables['var4']['action'] = 'activity';
    $variables['var4']['func'] = 'show';
    //récupération des ids
       $variables_chaine = explode("-", $variables['var3'][0]);
       $variables['var4']['id']=$variables_chaine[count($variables_chaine)+1];

}

Do you think that the CB Activity url is built with all these variables ? or does the parse interfere with the default joomla parse which makes that the id is not retrieved ?

Please Log in to join the conversation.

1 year 5 months ago #331721 by krileon
Replied by krileon on topic CB autoaction route triggers
I cannot help you write the parsing code. Use my example provided early as a 1 to 1 copy to auto actions and give that a try to be sure it's working first. Then go ahead with making changes as needed. As I explained earlier routing is not a simple task and it's very easy to break.


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 #331732 by activha
Replied by activha on topic CB autoaction route triggers
I tried your code but it fails with the error :
Exception Type: TypeError
File: libraries/src/Router/SiteRouter.php
Line: 442
Message: implode(): Argument #2 ($array) must be of type ?array, string given

The code that I wrote seems to work for the build but not for the parse.
I tried different options by commenting some variables needed to build the url but everything fails
if ( isset( $variables['var3'][0]) && ($variables['var3'][0] !== 'activity')) {
//     $variables['var4']['option'] = 'com_comprofiler';
//     $variables['var4']['view'] = 'pluginclass';
//     $variables['var4']['plugin'] = 'cbactivity';
//     $variables['var4']['action'] = 'activity';
//     $variables['var4']['func'] = 'show';
    //récupération des ids
       $variables_chaine = explode("-", $variables['var3'][0]);
       $variables['var4']['id']=$variables_chaine[count($variables_chaine)+1];

}
That's strange because this code does get the id of the activity correctly.

Do you have an idea ?

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.281 seconds

Facebook Twitter LinkedIn