Hi,
I would like to share a "HOW TO" use case.
I use to have the CB Birthday module from "CB Birthday for Community Builder" by michal.prochaczek.pl
As it might be not supported by Joomla 4, I made a simple CB Birthday module, using :
- Community Builder Online module
- CB Auto actions
Add 2 CB field
- cb_birthdate (date field, where the real birth date '1985-08-18' of the user is stored)
- cb_countdown_birthday (numeric field, no visible on profile, this field will be filled by CB Auto actions). This field will tell how many day are left before the birthday
Add Automatic action into the CB Auto action plugin
Type : request
Trigger : no trigger, I use cron link
Action : request :
Code:
update #__comprofiler AS a set a.`cb_countdown_birthday` = (select CASE WHEN `cb_birthdate` = '0000-00-00' THEN '9999' WHEN CONCAT(YEAR(now()),RIGHT(`cb_birthdate`,6)) < now() THEN DATEDIFF(ADDDATE(CONCAT(YEAR(now()),RIGHT(`cb_birthdate`,6)), INTERVAL 1 year),now()) ELSE DATEDIFF(CONCAT(YEAR(now()),RIGHT(`cb_birthdate`,6)),now()) END from #__comprofiler AS b where b.`id` = a.`id`);
The request will count the number of day left before the birthdate modified with current year
I have an external cron that will call the url to update at 00:01 every night
Add Community Builder Online module :
Module Tab
Display Mode = Custom Latest
User text =
Code:
<span class="label label-default">[cb:date format="d/m" date="[cb_birthdate]" /]</span><div class="block" style="line-height: normal;margin-bottom: 28px;"><a href="/url_to_userprofile-[user_id]"><img src="[avatar]"/></a>
<span class="myclass"><a href="/url_to_userprofile-[user_id]">[firstname] [lastname]</a></span>[cb:if cb_countdown_birthday="0"] <i class="fa fa-2x fa-gift"></i>[/cb:if]
</div>
Limit = 7 (or the number of CB User you want to display)
Custom Latest Tab
Field = cb_countdown_birthday
Direction = Ascending
1 functionnality is missing in this solution :
It's not really smart because it display 7 results (the Limit parameters), and doesn't display as many result as birthday. For instance, if a day 10 users have there birthday, only 7 results will be display. If no one has his birthday on a day, the next 7 birthday will be displayed... It's simple and less smart than "CB Birthday for Community Builder" by michal.prochaczek.pl