Calendar's categories - how to predetermine which categories are checked?

All categories of the calendar are checked by default and all events will show up in the calendar.
Can categories be select during onLoad or onScriptInit?

This is the right question, in the right place.
I am also very interested in this, but I have not yet managed to find out.

Maybe very few users use a calendar and nobody knows the solution.

to activate category at startup - onscriptinitcalendar event

?>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
    $( document ).ready(function() {
        filterCategory('EFF');
        filterCategory('SCNULLCAT');
    });
</script>
<?php
1 Like

Thank you very much nonkelmike for this solution.

Now I can progress and start exploring how each user will only show his categories.

Since there is no onFooter event in the calendar app I think it’s the only way to solve this.

Use the inspector to get your correct parameter to use in the filterCategory function

I will research a little and when I find a solution I will publish it here.

OK, as I said, I will continue to explore this, because I need a little different solution.

The given solution from nonkelmike is very good for a calendar used by everyone.
And on the basis of his solution, a new solution was created.

But I needed a solution for an individual user, that is, a calendar based on the user.
Therefore, I added new field in the user table named id_speciality field in which by double select I add the individual of the categories in the calendar, which I do not want to display as “checked”
For example:
the user has the following values in the id_speciality table: 30; 31; 34; 37
These categories will be “unchecked” when the calendar is displayed
The solution code is as follows:

//******************************************************************************************************************************************

$check_sql = "SELECT name_user, id_speciality FROM user WHERE id_user = " . [var_user];
sc_lookup(rs, $check_sql);

if (isset({rs[0][0]})) // Row found
{
$disp_name = {rs[0][0]};
$filter_category = {rs[0][1]};
}
else{
$disp_name = “”;
$filter_category = “”;
}

echo “<span style=‘font-size: 18px;font-weight: bold;’>”.{lang_tbl_event}.": “.$disp_name.”</span>";

// ******************************************************************************************************************************************

$result = explode(";",$filter_category);

// var_dump($result); // ***** Check if result is OK *****

?>

<script src="<?php echo sc_url_library(‘sys’, ‘jquery-3.2.0’, ‘jquery-3.2.0.min.js’); ?>"></script>

<script>

$( document ).ready(function() {

<?php foreach ($result as $key => $value) { ?>
var val = “<?php echo $value ?>”;
filterCategory(val);
<?php } ?>

});

</script>

<?php
// ******************************************************************************************************************************************

Now I think that this topic is solved in all possible ways and uses.

1 Like

I’m sure the above solution used to work great, but in the current version of SC I can only get one single option on the category list to be unchecked in my calendar. Even using the hard coded version below only unchecks category 7, it does not uncheck category 8.

?>

<?PHP Have I missed something?

Just as other codes, this code doesn’t work anymore…
Can somebody please give an example how to get this code start in the new SC enviroment