<script type="text/javascript" src="/web/templates/default/admin/ckeditor/ckeditor.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.12/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.12/js/jquery.dataTables.js"></script>

<div>
    <h2>Page Manager</h2>

    <form action="/admin/template" method="post">
        <table width="100%"><tr><td>
        <table id="template" class="display">
            <thead>
            <tr>
                <th>№</th>
                <th>Title</th>
                <th>Edit</th>
                <th>Delete</th>
            </tr>
            </thead>
            <tbody>
            {$i=1}
            {foreach $Pages item=page}
                <tr>
                    <td>{$i}</td>
                    <td>{current( explode('.',$page))}</td>
                    <td><button value="{$page}" name="update_page">Update</button></td>
                    <td><button value="{$page}" name="delete_page">Delete</button></td>
                </tr>
                {$i=$i+1}
            {/foreach}
            </tbody>
        </table>
                </td></tr></table>
    </form>
    <h3>Add/Edit Page</h3>

    <div id="news">
        <form action="/admin/template" method="post">
            <table width="100%">
                <tr>
                    <th>Название</th>
                    <td><input type="text" value="{$Update.Title}" name="new_page_title"></td>
                </tr>

                <tr>
                    <th colspan="2">Описание</th>
                </tr>
                <tr>
                    <td colspan="2"><textarea placeholder="Content" name="page_content">{$Update.Content}</textarea></td>
                </tr>
                <tr>
                    <td colspan="2"><button class="button_send"  name="page_btn" value="{$Update.Title}">Отправить</button></td>
                </tr>
            </table>
        </form>
    </div>

</div>
<script type="text/javascript">
    $(document).ready(function(){
        $('#template').DataTable();
    });
    CKEDITOR.replace("page_content");
    CKEDITOR.replace("news_desc");
</script>
