Skip to Content Skip to Menu

Need help for Menu item on Auto Action

2 years 1 week ago - 2 years 1 week ago #331578 by EWRobertRiou
Need help for Menu item on Auto Action was created by EWRobertRiou
Hi,

Here's what i want to do.

I have un first Database Table with a date and a link ; for exemple :
| ---- date ---- | ---    link                            - |
| 02-02-2022 | www.mysite-aa.com |
| 04-04-2022 | www.mysite-bb.com |
| 06-06-2022 | www.mysite-cc.com |

A second table with user_id, and a code wich is 0 or 1 :
| -- user_id --  |  -- code -- |
|        1           |       0         |
|        2           |       1         |
|        3           |       0         |

And a Menu Item, let's call it "OutsideLink"

If the today's date exists in the first table and if the code for the logged user_id is 1 in the second table
then when the user clicks on "OutsideLink", a new tab open on  www.mysite corresponding to the today's date.

if the today's date dosen't exist in the first table or if the code for the logged user_id is 0 in the second table
then when the user clicks on "OutsideLink", a message (or an article with a message) that indicate an error
An alternative would be to hide the link  "OutsideLink" in this case.

I guess this could be done with a  Menu  item on an Auto Action, type SQL request fired on UserLogin.
But i can't figure out how i can do

Thanks for your help
Regards
Last edit: 2 years 1 week ago by EWRobertRiou.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48541
  • Thanks: 8290
  • Karma: 1445
2 years 1 week ago #331595 by krileon
Replied by krileon on topic Need help for Menu item on Auto Action
I can only help you in regards to the initial setup, but I cannot help you code your solution. This will require SQL and likely PHP experience. Below would be the initial setup.

Global
Triggers: None
Type: Query
User: Self
Access: Everybody
Action
Query:
Code:
SELECT a.`link`  FROM `#__my_link_table` AS a  LEFT JOIN `#_my_code_table` AS b  ON b.`user_id` = '[user_id]'  WHERE a.`date` = CURDATE()  AND b.`code` = 1  LIMIT 1
Output
Display: Redirect
URL:
Code:
[cb:if content!=""][content][cb:else]index.php[/cb:else][/cb:if]

The above for example should redirect to the link if the query returns one otherwise redirect to home page. Next you'd create a Joomla menu item with a menu type of Community Builder > Plugin then select CB Auto Actions for Plugin and supply your auto actions id to the Actions parameter to have it be a menu item.

Note this is just an example and is not tested, but should get you started. I cannot help you code a solution beyond this simple example without a Business Membership , sorry.


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum