-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
05 - Add a page template Event overview to the website
- Loading branch information
1 parent
9d0a8af
commit b5f98f1
Showing
3 changed files
with
148 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?xml version="1.0" ?> | ||
<template xmlns="http://schemas.sulu.io/template/template" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd"> | ||
|
||
<key>event_overview</key> | ||
|
||
<view>pages/event_overview</view> | ||
<controller>Sulu\Bundle\WebsiteBundle\Controller\DefaultController::indexAction</controller> | ||
<cacheLifetime>86400</cacheLifetime> | ||
|
||
<meta> | ||
<title lang="en">Event Overview</title> | ||
<title lang="de">Veranstaltungsübersicht</title> | ||
</meta> | ||
|
||
<properties> | ||
<property name="title" type="text_line" mandatory="true"> | ||
<meta> | ||
<title lang="en">Title</title> | ||
<title lang="de">Titel</title> | ||
</meta> | ||
<params> | ||
<param name="headline" value="true"/> | ||
</params> | ||
|
||
<tag name="sulu.rlp.part"/> | ||
</property> | ||
|
||
<property name="url" type="resource_locator" mandatory="true"> | ||
<meta> | ||
<title lang="en">Resourcelocator</title> | ||
<title lang="de">Adresse</title> | ||
</meta> | ||
|
||
<tag name="sulu.rlp"/> | ||
</property> | ||
|
||
<property name="article" type="text_editor"> | ||
<meta> | ||
<title lang="en">Article</title> | ||
<title lang="de">Artikel</title> | ||
</meta> | ||
</property> | ||
|
||
<property name="events" type="smart_content"> | ||
<meta> | ||
<title lang="en">Events</title> | ||
<title lang="de">Veranstaltungen</title> | ||
</meta> | ||
|
||
<params> | ||
<param name="provider" value="events"/> | ||
</params> | ||
</property> | ||
</properties> | ||
</template> |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends "base.html.twig" %} | ||
|
||
{% block content %} | ||
<section class="jumbotron text-center"> | ||
<div class="container"> | ||
<h1 class="jumbotron-heading">{{ content.title }}</h1> | ||
<p class="lead text-muted">{{ content.article|raw }}</p> | ||
</div> | ||
</section> | ||
|
||
<div class="container marketing"> | ||
<div class="row"> | ||
{% for event in content.events %} | ||
<div class="col-lg-4 text-center"> | ||
<h2 class="event-title">{{ event.title }}</h2> | ||
<p>{{ event.teaser }}</p> | ||
<p> | ||
<a class="btn btn-secondary" href="{{ path('app.event', {id: event.id}) }}" role="button"> | ||
View details » | ||
</a> | ||
</p> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
{% endblock %} |
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Tests\Functional\Pages; | ||
|
||
use App\Tests\Functional\Traits\EventTrait; | ||
use App\Tests\Functional\Traits\PageTrait; | ||
use Sulu\Bundle\TestBundle\Testing\SuluTestCase; | ||
use Sulu\Component\DocumentManager\DocumentManagerInterface; | ||
use Symfony\Bundle\FrameworkBundle\KernelBrowser; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class EventOverviewTest extends SuluTestCase | ||
{ | ||
use EventTrait; | ||
use PageTrait; | ||
|
||
/** | ||
* @var KernelBrowser | ||
*/ | ||
private $client; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->client = $this->createWebsiteClient(); | ||
$this->initPhpcr(); | ||
} | ||
|
||
public function testEventOverview(): void | ||
{ | ||
$event1 = $this->createEvent('Sulu is awesome', 'en'); | ||
$this->enableEvent($event1); | ||
$event2 = $this->createEvent('Symfony Live is awesome', 'en'); | ||
$this->enableEvent($event2); | ||
$event3 = $this->createEvent('Disabled', 'en'); | ||
|
||
$this->createPage( | ||
'event_overview', | ||
'example', | ||
[ | ||
'title' => 'Symfony Live', | ||
'url' => '/events', | ||
'published' => true, | ||
] | ||
); | ||
|
||
$crawler = $this->client->request(Request::METHOD_GET, '/en/events'); | ||
|
||
$response = $this->client->getResponse(); | ||
$this->assertInstanceOf(Response::class, $response); | ||
$this->assertSame(Response::HTTP_OK, $response->getStatusCode()); | ||
$this->assertStringContainsString('Symfony Live', $crawler->filter('h1')->html()); | ||
$this->assertNotNull($content = $crawler->filter('.event-title')->eq(0)->html()); | ||
$this->assertStringContainsString($event1->getTitle() ?: '', $content); | ||
$this->assertNotNull($content = $crawler->filter('.event-title')->eq(1)->html()); | ||
$this->assertStringContainsString($event2->getTitle() ?: '', $content); | ||
} | ||
|
||
protected static function getDocumentManager(): DocumentManagerInterface | ||
{ | ||
return static::getContainer()->get('sulu_document_manager.document_manager'); | ||
} | ||
} |