2017 © Pedro Peláez
 

symfony-bundle block-bundle

WYSIWIG HTML editable blocks and entities bundle

image

arkounay/block-bundle

WYSIWIG HTML editable blocks and entities bundle

  • Tuesday, October 24, 2017
  • by Arkounay
  • Repository
  • 2 Watchers
  • 2 Stars
  • 121 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 11 Versions
  • 5 % Grown

The README.md

Arkounay BlockBundle - Symfony 3 wysiwyg inline edition

This lightweight and opinionated bundle allows to quickly render HTML blocks editable with a WYSIWYG editor (TinyMCE), either via the provided PageBlock entity, or directly already existing entities through custom twig functions., (*1)

alt tag, (*2)

Getting started

  • Download the files:
composer require arkounay/block-bundle
  • In AppKernel.php add the bundle:
new Arkounay\BlockBundle\ArkounayBlockBundle()
  • Then, run the following command:
php bin/console assets:install 
  • In your twig template, you will then need to import the required assets:, (*3)

    • CSS: twig {% include '@ArkounayBlock/assets/include_css.html.twig' %}
    • JS (requires jQuery and TinyMCE):, (*4)

      {# Import jQuery and TinyMCE: #}
      {% if has_inline_edit_permissions() %}
          
          
      {% endif %}
      
      {# Then the default bundle's JavaScript: #}
      {% include '@ArkounayBlock/assets/include_js.html.twig' %}
      
  • In routing.yml, you will need to import the Ajax route:
 block:
     resource: "@ArkounayBlockBundle/Resources/config/routing.yml"
  • Then update your database schema to add the provided PageBlock entity php bin/console doctrine:schema:update --force

Usage

To add an editable block, simply add this in a twig file:, (*5)

{{ render_block('block_id') }}

The first time you're going to edit it, a new PageBlock entity will be created in your database., (*6)

To edit an already existing entity text, you can add the following line:, (*7)

{{ render_entity_field(entity, 'field') }}

For example, with a "News" entity, you could add this to make its content editable:, (*8)

{{ render_entity_field(news, 'content') }}
{# instead of {{ news.content }} #}

Those who don't have editing permissions will see the field as if {{ news.content }} was directly called., (*9)

There is also another version with less editing options, usually for shorter texts:, (*10)

{{ render_plain_entity_field(entity, 'field') }}

Once you click on "Save", a single Ajax request is sent to persist and flush changed entities., (*11)

Notes

  • By default, only users with the ROLE_ADMIN permission can edit inline text. To edit the allowed roles, you can edit your config.yml yml arkounay_block: roles: ['IS_AUTHENTICATED_ANONYMOUSLY'] # Will allow anyone to edit inline!
  • To edit TinyMCE, create your own @ArkounayBlock/assets/include_js.html.twig, (*12)

  • You can also edit the .js-arkounay-block-bundle-editable to change the borders of the editable blocks., (*13)

  • In a twig file, you can use the function has_inline_edit_permissions() to see if a user has inline edit permissions. This can be useful if you want to import jQuery or TinyMCE only for these users., (*14)

  • By default, a div will be surrounding the editable text when connected. You can choose another tag with the third parameter, i.e for a span:, (*15)

 {{ render_block('block_id', true, 'span') }}

you can also call this shortcut:, (*16)

{{ render_span_block('block_id') }}

The Versions

24/10 2017

dev-master

9999999-dev https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin M

inline bundle symfony tinymce wysiwig

20/01 2017

1.2.7

1.2.7.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin M

inline bundle symfony tinymce wysiwig

20/01 2017

1.2.6

1.2.6.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin M

inline bundle symfony tinymce wysiwig

19/12 2016

1.2.5

1.2.5.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin Mozzati

inline bundle symfony tinymce wysiwig

15/12 2016

1.2.4

1.2.4.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin Mozzati

inline bundle symfony tinymce wysiwig

15/12 2016

1.2.3

1.2.3.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin Mozzati

inline bundle symfony tinymce wysiwig

13/12 2016

1.2.2

1.2.2.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin Mozzati

inline bundle symfony tinymce wysiwig

29/11 2016

1.2.1

1.2.1.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin Mozzati

inline bundle symfony tinymce wysiwig

21/11 2016

1.2

1.2.0.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin Mozzati

inline bundle symfony tinymce wysiwig

20/11 2016

1.1

1.1.0.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin Mozzati

inline bundle symfony tinymce wysiwig

20/11 2016

1.0

1.0.0.0 https://github.com/Arkounay/BlockBundle

WYSIWIG HTML editable blocks and entities bundle

  Sources   Download

The Requires

 

by Antonin Mozzati

inline bundle symfony tinymce wysiwig