Commit f67f2b9f by halweg

feat : 硬编码移动至joshine模块

parent ec1b86e9
...@@ -130,4 +130,71 @@ class Topmenu extends JoshineMenu ...@@ -130,4 +130,71 @@ class Topmenu extends JoshineMenu
return "<span class='{$class}'>".$this->escapeHtml($text) .'</span>'; return "<span class='{$class}'>".$this->escapeHtml($text) .'</span>';
} }
protected function _addSubMenu($child, $childLevel, $childrenWrapClass, $limit)
{
$html = '';
if (!$child->hasChildren()) {
return $html;
}
$colStops = [];
if ($childLevel == 0 && $limit) {
$colStops = $this->_columnBrake($child->getChildren(), $limit);
}
$name = $child->getData('name');
$name = strtoupper($name);
if ($name == 'BODYSUITS' || $name == 'SUPERDEAL' || $name == 'CONTROL PANTIES' || $name == 'CONTROL PANTIES' || $name == 'CORSETS& WAIST TRAINER' ) {
$html .= '<div class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= '<div class="row">';
$html .= '<ul class="subchildmenu col-sm-12 mega-columns columns4">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
} elseif ($name == 'SHAPEWEAR') {
$html .= '<div class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= '<div class="row">';
$html .= '<ul class="subchildmenu col-sm-8 mega-columns columns4">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
$html .= '<div class="menu-right-block col-sm-4">';
$html .= $this->getLayout()
->createBlock(\Magento\Cms\Block\Block::class)
->setBlockId('catpic') //replace my_cmsblock_identifier with real CMS bock identifier
->toHtml();
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
} elseif ($name == 'SERVICES') {
$html .= '<div class="level' . $childLevel . ' ' . $childrenWrapClass . ' col-sm-11">';
$html .= '<div class="row">';
$html .= '<ul class="subchildmenu col-sm-9">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
} else if($childLevel == 0) {
$html .= '<div class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= '<div class="row">';
$html .= '<ul class="subchildmenu col-sm-12 mega-columns columns4">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
} else{
$html .= '<ul class="level' . $childLevel . '">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
}
return $html;
}
} }
<?xml version="1.0" ?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<fieldset name="display_settings">
<field name="badge" sortOrder="300">
<argument name="data" xsi:type="array">
<item name="options" xsi:type="object">Joshine\Category\Model\Category\Attribute\Source\Badge</item>
<item name="config" xsi:type="array">
<item name="required" xsi:type="boolean">false</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">false</item>
</item>
<item name="dataType" xsi:type="string">string</item>
<item name="formElement" xsi:type="string">select</item>
<item name="label" translate="false" xsi:type="string">Badge</item>
</item>
</argument>
</field>
</fieldset>
</form>
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<css src="Joshine_Category::css/topmenu.css"/>
</head>
</page>
\ No newline at end of file
@media (min-width: 1024px) {
span.ui-menu-icon-1 {
top: -13px;
right: 12px;
background-color: #0cc485;
position: absolute;
text-transform: uppercase;
font: inherit;
font-size: 9px;
padding: 3px;
border-radius: 2px;
line-height: 1.2;
color: #ffffff;
min-width: 35px;
text-align: center;
}
span.ui-menu-icon-1.ui-icon-1:before {
border-top-color: #0cc485;
}
span.ui-menu-icon-2 {
top: -13px;
right: 24px;
background-color: #eb2771;
position: absolute;
text-transform: uppercase;
font: inherit;
font-size: 9px;
padding: 3px;
border-radius: 2px;
line-height: 1.2;
color: #ffffff;
min-width: 35px;
text-align: center;
}
span.ui-menu-icon-2.ui-icon-2:before {
border-top-color: #eb2771;
}
span.ui-menu-icon-3 {
top: -13px;
right: 24px;
background-color: #df0e0e;
position: absolute;
text-transform: uppercase;
font: inherit;
font-size: 9px;
padding: 3px;
border-radius: 2px;
line-height: 1.2;
color: #ffffff;
min-width: 35px;
text-align: center;
}
span.ui-menu-icon-3.ui-icon-3:before {
border-top-color: #df0e0e;
}
span.ui-menu-icon-1:before,
span.ui-menu-icon-2:before,
span.ui-menu-icon-3:before {
left: 3px;
bottom: -6px;
}
span.ui-menu-icon-1:before,
span.ui-menu-icon-2:before,
span.ui-menu-icon-3:before {
content: "";
position: absolute;
width: 3px;
height: 3px;
border: 3px solid transparent;
}
}
@media (max-width: 1024px) {
span.ui-menu-icon-1 {
top: 50%;
right: 36px;
margin-top: -7px;
position: absolute;
text-transform: uppercase;
font: inherit;
font-size: 9px;
padding: 2px;
border-radius: 2px;
line-height: 1;
color: #fff;
}
span.ui-menu-icon-1.ui-icon-1 {
background-color: #0cc485 !important;
}
span.ui-menu-icon-1:before {
content: "";
position: absolute;
width: 3px;
height: 3px;
border: 3px solid transparent;
left: -6px;
bottom: 3px;
}
span.ui-menu-icon-1.ui-icon-1:before {
border-right-color: #0cc485 !important;
}
span.ui-menu-icon-2 {
top: 50%;
right: 36px;
margin-top: -7px;
position: absolute;
text-transform: uppercase;
font: inherit;
font-size: 9px;
padding: 2px;
border-radius: 2px;
line-height: 1;
color: #fff;
}
span.ui-menu-icon-2.ui-icon-2 {
background-color: #eb2771 !important;
}
span.ui-menu-icon-2:before {
content: "";
position: absolute;
width: 3px;
height: 3px;
border: 3px solid transparent;
left: -6px;
bottom: 3px;
}
span.ui-menu-icon-2.ui-icon-2:before {
border-right-color: #eb2771 !important;
}
span.ui-menu-icon-3 {
top: 50%;
right: 36px;
margin-top: -7px;
position: absolute;
text-transform: uppercase;
font: inherit;
font-size: 9px;
padding: 2px;
border-radius: 2px;
line-height: 1;
color: #fff;
}
span.ui-menu-icon-3.ui-icon-3 {
background-color: #df0e0e !important;
}
span.ui-menu-icon-3:before {
content: "";
position: absolute;
width: 3px;
height: 3px;
border: 3px solid transparent;
left: -6px;
bottom: 3px;
}
span.ui-menu-icon-3.ui-icon-3:before {
border-right-color: #df0e0e !important;
}
}
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved. * Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details. * See COPYING.txt for license details.
*/ */
namespace Magento\Theme\Block\Html; namespace Magento\Theme\Block\Html;
use Magento\Backend\Model\Menu; use Magento\Backend\Model\Menu;
...@@ -58,8 +57,7 @@ class Topmenu extends Template implements IdentityInterface ...@@ -58,8 +57,7 @@ class Topmenu extends Template implements IdentityInterface
NodeFactory $nodeFactory, NodeFactory $nodeFactory,
TreeFactory $treeFactory, TreeFactory $treeFactory,
array $data = [] array $data = []
) ) {
{
parent::__construct($context, $data); parent::__construct($context, $data);
$this->nodeFactory = $nodeFactory; $this->nodeFactory = $nodeFactory;
$this->treeFactory = $treeFactory; $this->treeFactory = $treeFactory;
...@@ -194,169 +192,9 @@ class Topmenu extends Template implements IdentityInterface ...@@ -194,169 +192,9 @@ class Topmenu extends Template implements IdentityInterface
$colStops = $this->_columnBrake($child->getChildren(), $limit); $colStops = $this->_columnBrake($child->getChildren(), $limit);
} }
$name = $child->getData('name'); $html .= '<ul class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$name = strtoupper($name); $html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
if ($name == 'BODYSUITS' || $name == 'SUPERDEAL' || $name == 'CONTROL PANTIES' || $name == 'CONTROL PANTIES' || $name == 'CORSETS& WAIST TRAINER' ) {
$html .= '<div class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= '<div class="row">';
$html .= '<ul class="subchildmenu col-sm-12 mega-columns columns4">';
$html .= $this->_getHtmlStyle1($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
} elseif ($name == 'SHAPEWEAR') {
$html .= '<div class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= '<div class="row">';
$html .= '<ul class="subchildmenu col-sm-8 mega-columns columns4">';
$html .= $this->_getHtmlStyle2($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
$html .= '<div class="menu-right-block col-sm-4">';
$html .= $this->getLayout()
->createBlock(\Magento\Cms\Block\Block::class)
->setBlockId('catpic') //replace my_cmsblock_identifier with real CMS bock identifier
->toHtml();
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
} elseif ($name == 'SERVICES') {
$html .= '<div class="level' . $childLevel . ' ' . $childrenWrapClass . ' col-sm-11">';
$html .= '<div class="row">';
$html .= '<ul class="subchildmenu col-sm-9">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
} else if($childLevel == 0) {
$html .= '<div class="level' . $childLevel . ' ' . $childrenWrapClass . '">';
$html .= '<div class="row">';
$html .= '<ul class="subchildmenu col-sm-12 mega-columns columns4">';
$html .= $this->_getHtmlStyle1($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
} else{
$html .= '<ul class="level' . $childLevel . '">';
$html .= $this->_getHtml($child, $childrenWrapClass, $limit, $colStops);
$html .= '</ul>';
}
return $html;
}
protected function _getHtmlStyle1(Node $menuTree,
$childrenWrapClass,
$limit,
array $colBrakes = []
)
{
$html = '';
$children = $menuTree->getChildren();
$childLevel = $this->getChildLevel($menuTree->getLevel());
$this->removeChildrenWithoutActiveParent($children, $childLevel);
$counter = 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
/** @var Node $child */
foreach ($children as $child) {
$child->setLevel($childLevel);
$child->setIsFirst($counter === 1);
$child->setIsLast($counter === $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = '';
$outermostClass = $menuTree->getOutermostClass();
if ($childLevel === 0 && $outermostClass) {
$outermostClassCode = ' class="' . $outermostClass . '" ';
$this->setCurrentClass($child, $outermostClass);
}
if ($this->shouldAddNewColumn($colBrakes, $counter)) {
$html .= '</ul></li><li class="column"><ul>';
}
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml(
$child->getName()
) . '</span></a>' . $this->_addSubMenu(
$child,
$childLevel,
$childrenWrapClass,
$limit
) . '</li>';
$counter++;
}
if (is_array($colBrakes) && !empty($colBrakes) && $limit) {
$html = '<li class="column"><ul>' . $html . '</ul></li>';
}
return $html;
}
protected function _getHtmlStyle2(Node $menuTree,
$childrenWrapClass,
$limit,
array $colBrakes = []
)
{
$html = '';
$children = $menuTree->getChildren();
$childLevel = $this->getChildLevel($menuTree->getLevel());
$this->removeChildrenWithoutActiveParent($children, $childLevel);
$counter = 1;
$childrenCount = $children->count();
$parentPositionClass = $menuTree->getPositionClass();
$itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
/** @var Node $child */
foreach ($children as $child) {
$child->setLevel($childLevel);
$child->setIsFirst($counter === 1);
$child->setIsLast($counter === $childrenCount);
$child->setPositionClass($itemPositionClassPrefix . $counter);
$outermostClassCode = '';
$outermostClass = $menuTree->getOutermostClass();
if ($childLevel === 0 && $outermostClass) {
$outermostClassCode = ' class="' . $outermostClass . '" ';
$this->setCurrentClass($child, $outermostClass);
}
if ($this->shouldAddNewColumn($colBrakes, $counter)) {
$html .= '</ul></li><li class="column"><ul>';
}
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml(
$child->getName()
) . '</span></a>' . $this->_addSubMenu(
$child,
$childLevel,
$childrenWrapClass,
$limit
) . '</li>';
$counter++;
}
if (is_array($colBrakes) && !empty($colBrakes) && $limit) {
$html = '<li class="column"><ul>' . $html . '</ul></li>';
}
return $html; return $html;
} }
...@@ -375,8 +213,7 @@ class Topmenu extends Template implements IdentityInterface ...@@ -375,8 +213,7 @@ class Topmenu extends Template implements IdentityInterface
$childrenWrapClass, $childrenWrapClass,
$limit, $limit,
array $colBrakes = [] array $colBrakes = []
) ) {
{
$html = ''; $html = '';
$children = $menuTree->getChildren(); $children = $menuTree->getChildren();
...@@ -410,13 +247,13 @@ class Topmenu extends Template implements IdentityInterface ...@@ -410,13 +247,13 @@ class Topmenu extends Template implements IdentityInterface
$html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>'; $html .= '<li ' . $this->_getRenderedMenuItemAttributes($child) . '>';
$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml( $html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>' . $this->escapeHtml(
$child->getName() $child->getName()
) . '</span></a>' . $this->_addSubMenu( ) . '</span></a>' . $this->_addSubMenu(
$child, $child,
$childLevel, $childLevel,
$childrenWrapClass, $childrenWrapClass,
$limit $limit
) . '</li>'; ) . '</li>';
$counter++; $counter++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment