<?php

require_once $path . 'cms/templates/controllers/includes/sidebar_controller.php';


if (!empty($p->pagedata['Attachments'])) {

    $attachments = [];

    foreach ($p->pagedata['Attachments'] as $attachment) {
        $attachment_file_path =  SITE_PATH . '/uploads/files/' . $attachment['File']['value'];
        $attachments[] = [
            'Title' => $attachment['Title']['value'],
            'File' => $attachment['File']['value'],
            'File Size' => round((filesize($attachment_file_path) / 1024), 2) . 'KB',
            'File Extension' => strtoupper(pathinfo($attachment_file_path)['extension']),
        ];
    }

    $twig->addGlobal('attachments', $attachments);

}
