CB autoaction route triggers

1 year 4 months ago #331755 by krileon
Replied by krileon on topic CB autoaction route triggers
&func is not required as default &func is "show". You would need to handle the case of there being no &func in both the build and parsing. GJ had to do this and it's a bit complicated. Suggest reviewing its code carefully for examples. You should see where it's doing multiple different reversal behaviors to account for the different URL structures.


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 4 months ago #331758 by krileon
Replied by krileon on topic CB autoaction route triggers
The onBuildRoute behavior I'd probably go with is probably something like the below at first glance based off your needs. It's not necessary to rewrite EVERY URL, but only those that you NEED to rewrite to your custom structure.
if ( ( $variables['var2'] !== 'cbactivity' ) || ( ! $variables['var4'] ) || ( ! isset( $variables['var4']['action'] ) ) ) {
	return;
}

// Check if the URL contains an action and that it is an activity URL
$queryAction					=	( $variables['var4']['action'] ?? '' );

if ( $queryAction !== 'activity' ) {
	return;
}

// Check if the URL contains a function and if not default to show function
$queryFunc						=	( $variables['var4']['func'] ?? 'show' );

if ( $queryFunc !== 'show' ) {
	return;
}

// Check if the URL contains an ID
$queryId						=	(int) ( $variables['var4']['id'] ?? 0 );

if ( ! $queryId ) {
	return;
}

// LOAD ACTIVITY OBJECT HERE BASED OFF $queryId

// IF NOT FOUND RETURN HERE TO ABORT REWRITE

// IF FOUND CHECK IF IT HAS WHATEVER DATA YOU WANT IN THE URL

// IF SAID DATA IS MISSING RETURN HERE TO ABORT REWRITE

// NOW BUILD THE URL SEGMENTS HERE LIKE THE FOLLOWING EXAMPLE
$variables['var3'][]			=	$queryAction;
$variables['var3'][]			=	$queryFunc;
$variables['var3'][]			=	$queryId;

// Remove the old query parameters above since we're converting this to segments
unset( $variables['var4']['action'] );
unset( $variables['var4']['func'] );
unset( $variables['var4']['id'] );


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 4 months ago - 1 year 4 months ago #331761 by activha
Replied by activha on topic CB autoaction route triggers
Thanks a lot for these suggestions !

I'm going to write a new review on joomla.org for you guys :-)
I must say that I didn't know anything about coding a few years ago, and by teaching me step by step, I think I can at least change a few things now.
Even if sometimes it's a bit frustrating not to have the answer right away, understanding it and building it is a much better way to progress.

Thanks a hundred times for this, for your time and for this special topic ;-)

Edit:
Tried to post a new review on JED, but it won't allow me to...
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

1 year 4 months ago #331771 by krileon
Replied by krileon on topic CB autoaction route triggers
Always glad to be of help! There's certainly a learning curve when you dig into the finer details of our products, but that's also what makes them so powerful! I hope to make things easier and smoother in CB 3.x where we can use some more modern practices and a good refresh on the UX. Joomla 4 is also implementing a sort of guided tour feature that extensions can also utilize so that will be interesting to see as well.

Edit:
Tried to post a new review on JED, but it won't allow me to...

We'll reach out to the Joomla team and see what's going on. Did you receive an error of any kind?


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 4 months ago #331775 by activha
Replied by activha on topic CB autoaction route triggers
Not sure about JED but it looks like I cannot review more than once the same extension...

A suggestion for the future, you could include a simple php code editor or load codemirror editor in autoactions to quickly review the simplest errors :-)

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.306 seconds

Facebook Twitter LinkedIn