CalendR icon indicating copy to clipboard operation
CalendR copied to clipboard

Boilerplate code not working

Open marcosdipaolo opened this issue 5 years ago • 3 comments

Is this app still working with php 7 and Laravel 5.8?

Because non of the site's bolierplate code is working.

I cannot biuld the calendar, it only renders the day names, Mon to Fri repeteadly.

thanks.

marcosdipaolo avatar Apr 18 '19 05:04 marcosdipaolo

@marcosdipaolo, thank you for your report.

Could you provide some build steps about this issue you mention?

It can help us to reproduce issue and help you to find the current problems.

BTW, I think this is the PHP package and it will be worked successfully in all frameworks.

peter279k avatar Apr 18 '19 05:04 peter279k

As i told you, the boiler plate code at the website doesn't provide a simple calendar, instead this comes out:

Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sunday

<?php
// Use the factory to get your period
$factory = new CalendR\Calendar;
$month = $factory->getMonth(2012, 01);
?>

<table>
    <?php // Iterate over your month and get weeks ?>
    <?php foreach ($month as $week): ?>
    <tr>
        <?php // Iterate over your month and get days ?>
        <?php foreach ($week as $day): ?>
            <?php //Check days that are out of your month ?>
            <td><?php echo $day ?></td>
        <?php endforeach ?>
    </tr>
    <?php endforeach ?>
</table>

marcosdipaolo avatar Apr 18 '19 14:04 marcosdipaolo

Hi @marcosdipaolo, sorry for my delay response. Please try this:

<?php require_once __DIR__ . '/vendor/autoload.php';  ?>
<?php $factory = new CalendR\Calendar;  ?>
<?php $month = $factory->getMonth(2012, 01) ?>

    <table>
    <?php // Iterate over your month and get weeks ?>
    <tr>
        <?php foreach (range(0, 6) as $index): ?>
        <th><?php echo ($month->getDays()[$index])->format('l'); ?></th>
        <?php endforeach ?>
    </tr>
    <?php for ($index=0; $index<count($month->getDays()); $index += 7): ?>
    <tr>
        <?php foreach (range(0, 6) as $number):  ?>
        <?php // Iterate over your month and get days ?>
        <?php if (($number + $index) >= count($month->getDays())) { break; } ?>
            <td><?php echo ($month->getDays()[$index+$number])->format('d'); ?></td>
        <?php endforeach ?>
    </tr>
    <?php endfor ?>
</table>

It seems that the boilerplate codes are not worked anymore. And I use alternative way to create the calendar (see above codes).

And it should be:

image

And just notice that I forked this repository to this repository.

Please submit issue on this issue URL if you've any other questions/issues :).

peter279k avatar May 07 '21 12:05 peter279k