Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hello!

I have implemented the events calendar of CouchCMS. I would like to have the event dates highlighted for each user.

The issue is that:
- User 1 posts some events
- User 2 posts some events
- User 1 is able to see the dates highlighted which are posted by user 2 and vice versa.

While it would be great if the events posted by user 1 show dates highlighted only to user 1 and not to user 2.

Is there a way to make cms:calendar tag know which user is logged in and then display the event dates highlighted which we posted by the logged in user?

Regards,
GXCPL (Priya)
Image
where innovation meets technology
By the docs, tag <cms:calendar> also accepts all the arguments of the pages tag. This can be used to further refine the types of pages that are shown as entries of the calendar.

It means, you can add the custom_field parameter to show events (dates) specific to the current user.
@trendoman,

I tried using custom_field but it was not helpful.

So i tried the following. The template that is use for the things to work in index.php.

When I do:
Code: Select all
<cms:pages masterpage='index.php'>
    <cms:show ctr_name /><br>
</cms:pages>

I get an output:
Name #1
Name #2
Name #3


But when I use the same index.php template in cms:calendar I have no output. So i tried cms:dump:
Code: Select all
<cms:calendar masterpage='index.php'>
    <cms:dump /><br>
</cms:calendar>

And got the output:
calendar
k_count_weeks: 5
k_calendar_date: 2022-09-01
k_calendar_year: 2022
k_calendar_month: 09
k_next_calendar_date: 2022-10-01
k_next_calendar_year: 2022
k_next_calendar_month: 10
k_prev_calendar_date: 2022-08-01
k_prev_calendar_year: 2022
k_prev_calendar_month: 08


Now since i do not get the editable regions defined in index.php while using cms:calendar tag, how can I use custom_field?

In index.php there is an editable ctr_owner defined as:
Code: Select all
<cms:editable name="ctr_owner" label="Created by" type="relation" masterpage="users/index.php" has="one" order="8" />

But that is not available in cms:calender with masterpage="index.php".

Can you or anyone suggest me something more?

Regards,
GXCPL (Priya)
Image
where innovation meets technology
Following code shows editable fields for my template, as per documentation of Calendar Concept:
Code: Select all
<cms:calendar id='' page_name='' date='2022-07' masterpage='gallery.php' show_future_entries='1' >
   <cms:weeks>
     <cms:days>
         <cms:entries>
            <cms:dump />
         </cms:entries>
     </cms:days>
   </cms:weeks>
</cms:calendar>


Unfortunately, it seems you are unlucky and either documentation is wrong or there is a bug in Couch or the 'custom_field' parameter was not coded for calendar tag. It does not work! I suggest to address this issue to the @KK. I also did not have success addding custom_field filtering to the calendar tag, despite what documentation says.

Meanwhile, you can use a workaround - in above sample I checked that id parameter works fine (also page_name parameter, just in case), so it means, you can save a list of ids from the pages tag (filtered as desired by dates and relation field, using custom_field and ids_only params) to a variable and supply this new variable to the id param of calendar. This should work.
@trendoman,

As you mentioned:
I also did not have success addding custom_field filtering to the calendar tag, despite what documentation says


I too had checked that before posting the previous reply. I hope @KK Sir reads this thread.

Regards,
GXCPL (Priya)
Image
where innovation meets technology
@trendoman,

Thanks for the headsup.
Meanwhile, you can use a workaround - in above sample I checked that id parameter works fine (also page_name parameter, just in case), so it means, you can save a list of ids from the pages tag (filtered as desired by dates and relation field, using custom_field and ids_only params) to a variable and supply this new variable to the id param of calendar. This should work.


since the ID attribute works I was able to achieve the output as a workaround.

I set a var for the ids or the event posts created by a user:
Code: Select all
<cms:set ctr_ids_for_calendar="<cms:pages masterpage='index.php' custom_field="ctr_owner=<cms:show show_ctr_owner_calendar />" show_future_entries='1' ids_only='1' />" scope="global" />


And then passed it to the id attribute of cms:calendar:
Code: Select all
<cms:calendar date="<cms:gpc 'cal' />" masterpage='index.php' show_future_entries='1' id=ctr_ids_for_calendar >
    ...
</cms:calendar>


And it solves the problem discussed above.

Regards,
GXCPL (Priya)

NOTE: If someone uses this, please remember this is a workaround, since the custom_field attribute does not work in cms:calendar tag.
Image
where innovation meets technology
6 posts Page 1 of 1