Skip to content

How to use

Teyir edited this page Sep 16, 2024 · 1 revision

Step 1 - Logic integration

Include the cookie consent logic after

opening tag:
<?php
if (PackageController::isInstalled('Simplecookies')) {
    CMW\Controller\Simplecookies\SimpleCookiesController::getInstance()->showCookieConsent();
}
?>

Step 2 - Theme integration

In your theme folder create a new directory "SimpleCookies", ex Public/Themes/$theme/Views/SimpleCookies

Create 2 files:

Step 2.1 - cookies.banner.php

Create a file cookies.banner.php.

This is an exemple:

<?php

use CMW\Manager\Env\EnvManager;
use CMW\Manager\Security\SecurityManager;
use CMW\Model\Simplecookies\SimpleCookiesModel;

//Import the SimpleCookies settings
$settings = SimpleCookiesModel::getInstance()->getSettings();

?>
<div class="cookies-consent">
    <h1><?= $settings->getBannerTitle() ?></h1>

    <?= $settings->getPageContent() ?>

    <form action="<?= EnvManager::getInstance()->getValue('PATH_URL') . 'api/cookies/consent' ?>" method="post">
        <?php (new SecurityManager())->insertHiddenToken(); ?>
        <button type="submit" name="consent" value="1">OK</button>
    </form>
</div>

Step 2.2 - main.view.php

Create a file main.view.php.

This is an exemple:

<?php

use CMW\Utils\Website;

/* @var string $content */

Website::setTitle("Cookies");
Website::setDescription("Informations sur les cookies que nous stockons sur le site " . Website::getWebsiteName());

?>

<section class="cookies-container">
    <?= $content ?>
</section>
Clone this wiki locally