Skip to content

Commit 399721b

Browse files
committed
Rendering helpers added
1 parent dc8b95b commit 399721b

6 files changed

Lines changed: 15 additions & 65 deletions

File tree

components/Counters.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<?php namespace NumenCode\Widgets\Components;
22

33
use Cms\Classes\ComponentBase;
4+
use NumenCode\Fundamentals\Traits\RenderingHelpers;
45

56
class Counters extends ComponentBase
67
{
8+
use RenderingHelpers;
9+
710
public $counters;
811

912
public function componentDetails(): array

components/Features.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
use Cms\Classes\ComponentBase;
44
use NumenCode\Widgets\Models\FeatureGroup;
5+
use NumenCode\Fundamentals\Traits\RenderingHelpers;
56

67
class Features extends ComponentBase
78
{
9+
use RenderingHelpers;
10+
811
public $group;
912

1013
public function componentDetails(): array
@@ -38,28 +41,11 @@ public function onRun()
3841
$this->group = $this->loadGroup();
3942
}
4043

41-
public function onRender()
42-
{
43-
if (!$layout = $this->property('layout')) {
44-
$layout = 'default';
45-
}
46-
47-
return $this->renderPartial('@' . $layout . '.htm');
48-
}
49-
5044
public function getTitleOptions(): array
5145
{
5246
return FeatureGroup::lists('title', 'id');
5347
}
5448

55-
public function getLayoutOptions(): array
56-
{
57-
return [
58-
'default' => 'Default',
59-
'media' => 'Default with pictures',
60-
];
61-
}
62-
6349
protected function loadGroup()
6450
{
6551
return FeatureGroup::find($this->property('title'));

components/Gallery.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
use Cms\Classes\ComponentBase;
44
use NumenCode\Widgets\Models\GalleryGroup;
5+
use NumenCode\Fundamentals\Traits\RenderingHelpers;
56

67
class Gallery extends ComponentBase
78
{
9+
use RenderingHelpers;
10+
811
public $gallery;
912
public $itemsPerRow;
1013

@@ -47,27 +50,11 @@ public function onRun()
4750
$this->itemsPerRow = $this->property('items_per_row') ?? 4;
4851
}
4952

50-
public function onRender()
51-
{
52-
if (!$layout = $this->property('layout')) {
53-
$layout = 'default';
54-
}
55-
56-
return $this->renderPartial('@' . $layout . '.htm');
57-
}
58-
5953
public function getTitleOptions(): array
6054
{
6155
return GalleryGroup::lists('title', 'id');
6256
}
6357

64-
public function getLayoutOptions(): array
65-
{
66-
return [
67-
'default' => 'Default',
68-
];
69-
}
70-
7158
protected function loadGallery()
7259
{
7360
return GalleryGroup::find($this->property('title'));

components/Highlights.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
use Cms\Classes\ComponentBase;
44
use NumenCode\Widgets\Models\HighlightGroup;
5+
use NumenCode\Fundamentals\Traits\RenderingHelpers;
56

67
class Highlights extends ComponentBase
78
{
9+
use RenderingHelpers;
10+
811
public $group;
912

1013
public function componentDetails(): array
@@ -38,27 +41,11 @@ public function onRun()
3841
$this->group = $this->loadGroup();
3942
}
4043

41-
public function onRender()
42-
{
43-
if (!$layout = $this->property('layout')) {
44-
$layout = 'default';
45-
}
46-
47-
return $this->renderPartial('@' . $layout . '.htm');
48-
}
49-
5044
public function getTitleOptions(): array
5145
{
5246
return HighlightGroup::lists('title', 'id');
5347
}
5448

55-
public function getLayoutOptions(): array
56-
{
57-
return [
58-
'default' => 'Default',
59-
];
60-
}
61-
6249
protected function loadGroup()
6350
{
6451
return HighlightGroup::find($this->property('title'));

components/Promotions.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
use Cms\Classes\ComponentBase;
44
use NumenCode\Widgets\Models\PromotionGroup;
5+
use NumenCode\Fundamentals\Traits\RenderingHelpers;
56

67
class Promotions extends ComponentBase
78
{
9+
use RenderingHelpers;
10+
811
public $group;
912

1013
public function componentDetails(): array
@@ -38,27 +41,11 @@ public function onRun()
3841
$this->group = $this->loadGroup();
3942
}
4043

41-
public function onRender()
42-
{
43-
if (!$layout = $this->property('layout')) {
44-
$layout = 'default';
45-
}
46-
47-
return $this->renderPartial('@' . $layout . '.htm');
48-
}
49-
5044
public function getTitleOptions(): array
5145
{
5246
return PromotionGroup::lists('title', 'id');
5347
}
5448

55-
public function getLayoutOptions(): array
56-
{
57-
return [
58-
'default' => 'Bootstrap 4',
59-
];
60-
}
61-
6249
protected function loadGroup()
6350
{
6451
return PromotionGroup::find($this->property('title'));
File renamed without changes.

0 commit comments

Comments
 (0)