devtronic/cms-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

A CMS Bundle for Symfony3

Installs: 110

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 2

Type:symfony-bundle

v1.0.5 2017-04-01 07:19 UTC

This package is auto-updated.

Last update: 2021-08-07 20:30:15 UTC


README

Status

Done

  • English Translation
  • German Translation
  • Show menus in Twig-Templates
  • Menu-, MenuItem-, Page-Entity
  • Sonata Admins
  • Make menu templates more dynamic

Open

  • Multi-Language DB Content
  • Stuff... :)

Installation

$ composer require --dev devtronic/cms-bundle
<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Ivory\CKEditorBundle\IvoryCKEditorBundle(),
            new Devtronic\CmsBundle\CmsBundle(),
        );
        // ...
        return $bundles;
    }
    // ...
}

Symfony >= 3.x

$ php bin/console assets:install --symlink --relative
$ php bin/console doctrine:schema:update --force
$ php bin/console cache:clear

Symfony <= 2.8.x

$ php app/console assets:install --symlink --relative
$ php app/console doctrine:schema:update --force
$ php app/console cache:clear

Configuration

# app/config/routing.yml
devtronic_cms_bundle:
    resource: "@CmsBundle/Controller/"
    type:     annotation
    prefix:   /cms # OR WHAT EVER YOU WANT (links goes example.com/cms/{page-slug})    

Usage

Show a menu in twig-template

{# anything.html.twig #}
{{ cms_menu("MENU SLUG GOES HERE") }}

{# or with a custom Menu Template #}
{{ cms_menu("MENU SLUG GOES HERE", "AnyBundle:Path:menu_template.html.twig") }}

Templates

Menu Template

{# app/Resources/CmsBundle/views/menu.html.twig #}
{# Types: 0: CMS Page, 1: Hyperlink, 2: Route #}

{# Top-Level Menu Entries #}
{% if menu.items is defined %}
    <ul class="nav navbar-nav">
        {% for item in menu.items %}
            {% if item.parentItem is null %}
                    {% if item.subItems | length %}
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ item.title }} <span class="caret"></span></a>
                            {% include 'CmsBundle::menu.html.twig' with {'menu': item} %}
                        </li>
                    {% else %}
                        <li>
                            {%  if item.type == 0 %}
                                <a href="{{ path('cms_page', {'slug': item.targetPage.slug}) }}">{{ item.title }}</a>
                            {% elseif item.type == 2 %}
                                <a href="{{ path(item.targetUrl) }}">{{ item.title }}</a>
                            {% else %}
                                <a href="{{ item.targetUrl }}">{{ item.title }}</a>
                            {% endif %}
                        </li>
                    {% endif %}
            {% endif %}
        {% endfor %}
    </ul>
{# Sub-Entries #}
{% elseif menu.subItems is defined %}
    <ul class="dropdown-menu">
        {% for item in menu.subItems %}
            {% if item.subItems | length %}
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ item.title }} <span class="caret"></span></a>
                    {% include 'CmsBundle::menu.html.twig' with {'menu': item} %}
                </li>
            {% else %}
                <li>
                    {%  if item.type == 0 %}
                        <a href="{{ path('cms_page', {'slug': item.targetPage.slug}) }}">{{ item.title }}</a>
                    {% elseif item.type == 2 %}
                        <a href="{{ path(item.targetUrl) }}">{{ item.title }}</a>
                    {% else %}
                        <a href="{{ item.targetUrl }}">{{ item.title }}</a>
                    {% endif %}
                </li>
            {% endif %}
        {% endfor %}
    </ul>
{% endif %}

Page Template

{# app/Resources/CmsBundle/views/Page/page.html.twig #}

{% extends "::base.html.twig" %}

{% block title %}{{ page.title }}{% endblock %}

{% block body %}
    <h1>{{ page.title }}</h1>
    {{ page.content | raw }}
{% endblock %}

Index Template

{# app/Resources/CmsBundle/views/Page/index.html.twig #}

{% extends "::base.html.twig" %}

{% block title %}{{ page.title }}{% endblock %}

{% block body %}
    <h1>{{ page.title }}</h1>
    {{ page.content | raw }}
{% endblock %}

FAQ

How can I link to the Frontpage?

As menuentry: Internal route to cms_index As Link in template: <a href="{{ path('cms_index') }}">Home</a>

How to contribute?

Translate the Bundle (send messages.LOCALE.xlf and your user-/name to admin@developer-heaven.de

Translation status

Language Translator Status
German Devtronic 100%
English Modius22 100%