Skip to content

Commit c4a5d19

Browse files
author
Roderik van der Veer
committed
Merge pull request #113 from Kunstmaan/feature/multiplePagePartTemplates
allow to override the default pp template with variable template
2 parents 30fed90 + 3fa265f commit c4a5d19

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

Entity/AbstractPagePart.php

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
namespace Kunstmaan\PagePartBundle\Entity;
4+
use Kunstmaan\NodeBundle\Entity\PageInterface;
45
use Kunstmaan\PagePartBundle\Helper\PagePartInterface;
56
use Kunstmaan\AdminBundle\Entity\AbstractEntity;
67
use Doctrine\ORM\Mapping as ORM;
@@ -21,4 +22,15 @@ public function getAdminView()
2122
{
2223
return $this->getDefaultView();
2324
}
25+
26+
/**
27+
* Use this method to override the default view for a specific page type.
28+
* Also, this implementation guarantees backwards compatibility.
29+
*
30+
* @return string
31+
*/
32+
public function getView(PageInterface $page = null)
33+
{
34+
return $this->getDefaultView();
35+
}
2436
}

Helper/PagePartInterface.php

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Kunstmaan\PagePartBundle\Helper;
44

5+
use Kunstmaan\NodeBundle\Entity\PageInterface;
56
use Symfony\Component\Form\AbstractType;
67

78
/**
@@ -24,6 +25,13 @@ public function getDefaultView();
2425
*/
2526
public function getAdminView();
2627

28+
/**
29+
* This method can be used to override the default view for a specific page type
30+
* @abstract
31+
* @return string
32+
*/
33+
public function getView(PageInterface $page = null);
34+
2735
/**
2836
* @return AbstractType
2937
*/
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{% for box in pageparts %}
22
{% set resource = box %}
3-
{% include box.defaultview %}
3+
{% include box.getView(page) %}
44
{% endfor %}

0 commit comments

Comments
 (0)