Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/975l/pageeditbundle

Create, modify and manage web pages
https://github.com/975l/pageeditbundle

symfony symfony-bundle symfony-cms tinymce twig-pages

Last synced: 4 months ago
JSON representation

Create, modify and manage web pages

Awesome Lists containing this project

README

        

# PageEditBundle

PageEditBundle does the following:

- Displays pages requested,
- Provides tools to edit content of pages, unless of doing it via a code editor,
- Integrates with your web design,
- Protects twig code from being formatted,
- Archives the files before replacing them in order to be able to retrieve old versions,
- Gives the possibility to create a `sitemap.xml̀` of managed files, setting their change frequency and priority,
- Allows to store specific templates in a `protected` folder to display it but not being able to modify it,
- Allows to create a PDF version of pages,

It is, of course, still possible to modify directly those files with an editor.

This Bundle relies on the use of [TinyMce](https://www.tinymce.com/), [jQuery](https://jquery.com/) and [Bootstrap](http://getbootstrap.com/).

[PageEditBundle dedicated web page](https://975l.com/en/pages/pageedit-bundle).

[PageEditBundle API documentation](https://975l.com/apidoc/c975L/PageEditBundle.html).

## Bundle installation

### Step 1: Download the Bundle

Use [Composer](https://getcomposer.org) to install the library

```bash
composer require c975l/pageedit-bundle
```

### Step 2: Enable the Bundle

Then, enable the bundle by adding them to the list of registered bundles in the `app/AppKernel.php` file of your project:

```php
Title of the page`.

The different Routes (naming self-explanatory) available are:

- pageedit_home
- pageedit_config
- pageedit_display
- pageedit_pdf
- pageedit_create
- pageedit_modify
- pageedit_duplicate
- pageedit_delete
- pageedit_dashboard
- pageedit_upload
- pageedit_slug
- pageedit_links
- pageedit_help

### Creation of PDF

PageEditBundle uses `KnpSnappyBundle` to generates PDF, which itself uses `wkhtmltopdf`. `wkhtmltopdf` requires that included files, like stylesheets, are included with an absolute url. But, there is a known problem with SSL, see [#3001](https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3001), which force you to downgrade openssl, like in [Gist](https://gist.github.com/kai101/99d57462f2459245d28b4f5ea51aa7d0).

You can avoid this problem by including the whole content of included files, which is what `wkhtmltopdf` does, in your html output. To integrate them easily, you can, as [c975L/SiteBundle](https://github.com/975L/SiteBundle) does, use [c975L/IncludeLibraryBundle](https://github.com/975L/IncludeLibraryBundle) with the following code:

```twig
{# in your layout.html.twig > head #}
{% if display == 'pdf' %}
{{ inc_content('bootstrap', 'css', '3.*') }}
{{ inc_content(absolute_url(asset('css/styles.min.css')), 'local') }}
{% else %}
{{ inc_lib('bootstrap', 'css', '3.*') }}
{{ inc_lib('cookieconsent', 'css', '3.*') }}
{{ inc_lib('fontawesome', 'css', '5.*') }}
{{ inc_lib(absolute_url(asset('css/styles.min.css')), 'local') }}
{% endif %}
```

### Integrate sub-pages

To add sub-pages in sub-folders, simply use a "/" as separator in the Url semantic field.

### Homepage specific

The home page can be managed via PageEdit, but as it is called at the root of the website it has a specificity. it's name is "home" and cannot be changed.

### Protect specific templates

If you need to protect specific templates (containing lot of Twig tag, Twig variable setting, etc. or if you don't want your final user to be able to modify them, to not break the website), simply put those templates in `templates/[folderPages]/protected`, they will be displayed as other, and included in the sitemap, but not available for modifications.
**You just need to encapsulate the content of the template within the `skeleton.html.twig`.**

### Use the Twig Extension to automate building menus

You can use the provided Twig Extension `folder_content()` to easily build menus based on the content of a specific folder, for this use the following code:

```html
{% set files = folder_content('specific_folder') %}


```

### Migrating existing files to PageEdit

To migrate existing files, simply move your existing templates in the folder defined in `templates/[folderPages]` (`folderPages` has been defined in Step 3 above), access to PageEdit dashboard and do the modifications. The skeleton will be added to new files and old ones will be archived.

You can use the command `git rm -r --cached templates/[folderPages]` to remove it from Git, if the folder was previously indexed. **Don't forget to make a copy of it, if you use Git as versionning system and if you have added this folder in the `.gitignore`, otherwise your files will be deleted at next commit !**

If files have been deleted by Git, simply use the code below:

```bash
git log #Gives you latest commit
git checkout #Indicate here the id of the commit obtained above
#Access to your files, copy/paste them somewhere else
git checkout HEAD #Get back to latest version
```

### Create Sitemap

In a console use `php bin/console pageedit:createSitemap` to create a `sitemap-[folderPages].xml` in the `web` folder of your project. You can use a crontab to generate it every day.
You can add this file in a `sitemap-index.xml`that groups all your sitemaps or directly use it if you have only one.

If this project **help you to reduce time to develop**, you can sponsor me via the "Sponsor" button at the top :)