-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
94 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,103 @@ | ||
Installation | ||
============ | ||
|
||
Make sure Composer is installed globally, as explained in the | ||
[installation chapter](https://getcomposer.org/doc/00-intro.md) | ||
of the Composer documentation. | ||
|
||
Applications that use Symfony Flex | ||
---------------------------------- | ||
|
||
Open a command console, enter your project directory and execute: | ||
# SuluEventBundle! | ||
This bundle was made based on pr of https://github.com/sulu/sulu-workshop. | ||
I made it to quickly install it in my projects. | ||
|
||
## Installation | ||
Install the package with: | ||
```console | ||
$ composer require <package-name> | ||
composer require manuxi/sulu-event-bundle | ||
``` | ||
|
||
Applications that don't use Symfony Flex | ||
---------------------------------------- | ||
|
||
### Step 1: Download the Bundle | ||
|
||
Open a command console, enter your project directory and execute the | ||
following command to download the latest stable version of this bundle: | ||
|
||
If you're *not* using Symfony Flex, you'll also | ||
need to add the bundle in your `config/bundles.php` file: | ||
```php | ||
Manuxi\SuluEventBundle\SuluEventBundle::class => ['all' => true], | ||
``` | ||
Please add the following to your `routes_admin.yaml`: | ||
```yaml | ||
sulu_event.admin: | ||
resource: '@SuluEventBundle/Resources/config/routes_admin.yml' | ||
``` | ||
...and the following to your `routes_website.yaml`: | ||
```yaml | ||
SuluEventBundle: | ||
resource: "@SuluEventBundle/Resources/config/routes.yml" | ||
``` | ||
Last but not least the entity tables must be created in the database. | ||
The tables which will be created are | ||
``` | ||
app_location, app_event_translation, app_event_seo_translation, app_event_seo and app_event | ||
``` | ||
See the needed queries with: | ||
```console | ||
$ composer require <package-name> | ||
php bin/console doctrine:schema:update --dump-sql | ||
``` | ||
Execute the queries above with: | ||
```console | ||
php bin/console doctrine:schema:update --force | ||
``` | ||
|
||
### Step 2: Enable the Bundle | ||
## Usage | ||
After granting the rights in the sulu admin area you should be able to create locations and events. | ||
use smart_content property type to show a list of events, e.g.: | ||
```xml | ||
... | ||
<block name="smart-content-events" default-type="smart-content-events"> | ||
<types> | ||
<type name="smart-content-events"> | ||
<properties> | ||
<property name="events" type="smart_content"> | ||
<meta> | ||
<title lang="en">Events</title> | ||
<title lang="de">Veranstaltungen</title> | ||
</meta> | ||
|
||
Then, enable the bundle by adding it to the list of registered bundles | ||
in the `config/bundles.php` file of your project: | ||
<params> | ||
<param name="provider" value="events"/> | ||
<param name="max_per_page" value="5"/> | ||
<param name="page_parameter" value="page"/> | ||
</params> | ||
</property> | ||
</properties> | ||
</type> | ||
</types> | ||
</block> | ||
... | ||
``` | ||
Example of the corresponding twig template for the event list: | ||
```html | ||
{% for event in events %} | ||
<div class="col"> | ||
<h2> | ||
{{ event.title }} | ||
</h2> | ||
<p> | ||
{{ event.startDate|format_datetime('full', 'none', locale=app.request.getLocale()) }} | ||
{% if endDate and startDate != endDate %} | ||
- {{ event.endDate|format_datetime('full', 'none', locale=app.request.getLocale()) }} | ||
{% endif %} | ||
</p> | ||
<p> | ||
{{ event.teaser|raw }} | ||
</p> | ||
<p> | ||
<a class="btn btn-primary" href="{{ path('event', {id: event.id, slug: event.title|slugify}) }}" role="button"> | ||
{{ "Read more..."|trans }} <i class="fa fa-angle-double-right"></i> | ||
</a> | ||
</p> | ||
</div> | ||
{% endfor %} | ||
``` | ||
The route to the single event follows the scheme: | ||
``` | ||
"en": "/events/{id}/{slug}", | ||
"de": "/veranstaltungen/{id}/{slug}" | ||
``` | ||
At the moment the template for the single event is located here | ||
`templates/pages/event.html.twig` | ||
|
||
```php | ||
// config/bundles.php | ||
## Configuration | ||
There exists no configuration yet. I'm on it :) | ||
|
||
return [ | ||
// ... | ||
<vendor>\<bundle-name>\<bundle-long-name>::class => ['all' => true], | ||
]; | ||
``` | ||
## Contributing | ||
For the sake of simplicity this extension was kept small. | ||
Please feel comfortable submitting issues or pull requests. As always I'd be glad to get your feedback to improve the extension :). |