mirror of
https://github.com/a2nt/silverstripe-webpack.git
synced 2024-10-22 17:05:31 +02:00
IMPROVEMENT: Submenu Widget
This commit is contained in:
parent
fdebf4abef
commit
5678bb0aee
39
app/src/Widgets/SubmenuWidget.php
Normal file
39
app/src/Widgets/SubmenuWidget.php
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
namespace Site\Widgets;
|
||||||
|
|
||||||
|
use Sheadawson\Linkable\Forms\LinkField;
|
||||||
|
use Sheadawson\Linkable\Models\Link;
|
||||||
|
use SilverStripe\AssetAdmin\Forms\UploadField;
|
||||||
|
use SilverStripe\Assets\Image;
|
||||||
|
use SilverStripe\Widgets\Model\Widget;
|
||||||
|
|
||||||
|
if (!class_exists(Widget::class)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SubmenuWidget extends Widget
|
||||||
|
{
|
||||||
|
private static $title = 'Sub-Menu';
|
||||||
|
private static $cmsTitle = 'Sub-Menu';
|
||||||
|
private static $description = 'Shows sub menu.';
|
||||||
|
private static $icon = '<i class="icon font-icon-tree"></i>';
|
||||||
|
private static $table_name = 'SubmenuWidget';
|
||||||
|
|
||||||
|
public function getPage()
|
||||||
|
{
|
||||||
|
$area = $this->Parent();
|
||||||
|
return \Page::get()->filter('SideBarID', $area->ID)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubmenu()
|
||||||
|
{
|
||||||
|
$page = $this->getPage();
|
||||||
|
|
||||||
|
$children = $page->Children();
|
||||||
|
$children = $children->count() ? $children : $page->Level(1)->Children();
|
||||||
|
|
||||||
|
return $children;
|
||||||
|
}
|
||||||
|
}
|
@ -20,7 +20,7 @@
|
|||||||
$Breadcrumbs
|
$Breadcrumbs
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% if $SideBarView && $SideBar.Widgets.Count %>
|
<% if $SideBarView && $SideBarView.Widgets.Count %>
|
||||||
<div class="$DefaultContainer">
|
<div class="$DefaultContainer">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-8">
|
<div class="col-md-8">
|
||||||
|
8
app/templates/Site/Widgets/BannerWidget.ss
Normal file
8
app/templates/Site/Widgets/BannerWidget.ss
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<img src="$Image.Fill(432,324).URL" alt="$Title" />
|
||||||
|
<% if $Link %>
|
||||||
|
<% with $Link %>
|
||||||
|
<a href="$URL"<% if $OpenInNewWindow %> target="_blank"<% end_if %> class="stretched-link">
|
||||||
|
<span class="sr-only">$Up.Title</span>
|
||||||
|
</a>
|
||||||
|
<% end_with %>
|
||||||
|
<% end_if %>
|
9
app/templates/Site/Widgets/SubmenuWidget.ss
Normal file
9
app/templates/Site/Widgets/SubmenuWidget.ss
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<% if $Submenu %>
|
||||||
|
<nav>
|
||||||
|
<ul class="nav flex-column">
|
||||||
|
<% loop $Submenu %>
|
||||||
|
<% include NavItem %>
|
||||||
|
<% end_loop %>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<% end_if %>
|
@ -27,8 +27,8 @@
|
|||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@a2nt/meta-lightbox": "^1.2.2",
|
"@a2nt/meta-lightbox": "^1.2.2",
|
||||||
"@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^1.3.0",
|
"@a2nt/ss-bootstrap-ui-webpack-boilerplate": "^1.3.2",
|
||||||
"yarn": "^1.21.0"
|
"yarn": "^1.21.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@google/markerclusterer": "^1.0.3",
|
"@google/markerclusterer": "^1.0.3",
|
||||||
@ -55,7 +55,7 @@
|
|||||||
"core-util-is": "^1.0.2",
|
"core-util-is": "^1.0.2",
|
||||||
"croppie": "^2.6.4",
|
"croppie": "^2.6.4",
|
||||||
"cross-env": "^5.2.1",
|
"cross-env": "^5.2.1",
|
||||||
"css-loader": "^3.3.0",
|
"css-loader": "^3.3.1",
|
||||||
"eslint": "^4.18.1",
|
"eslint": "^4.18.1",
|
||||||
"eslint-plugin-import": "^2.19.1",
|
"eslint-plugin-import": "^2.19.1",
|
||||||
"eslint-plugin-jquery": "^1.5.1",
|
"eslint-plugin-jquery": "^1.5.1",
|
||||||
@ -104,7 +104,7 @@
|
|||||||
"smooth-scroll": "^14.2.1",
|
"smooth-scroll": "^14.2.1",
|
||||||
"style-loader": "^0.19.0",
|
"style-loader": "^0.19.0",
|
||||||
"svg-url-loader": "^2.3.3",
|
"svg-url-loader": "^2.3.3",
|
||||||
"terser-webpack-plugin": "^2.2.2",
|
"terser-webpack-plugin": "^2.3.0",
|
||||||
"uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony-v2.8.22",
|
"uglify-js": "git://github.com/mishoo/UglifyJS2.git#harmony-v2.8.22",
|
||||||
"uglifyjs-webpack-plugin": "^2.2.0",
|
"uglifyjs-webpack-plugin": "^2.2.0",
|
||||||
"url-loader": "^0.6.2",
|
"url-loader": "^0.6.2",
|
||||||
|
Loading…
Reference in New Issue
Block a user