fix(main): Separate slide tpl from banner tpl
also added a toggle column for active in the group view
This commit is contained in:
@@ -39,6 +39,12 @@ customhtmlgroup_delete:
|
|||||||
defaults:
|
defaults:
|
||||||
_controller: 'Websmid\CustomHtml\Controller\CustomHtmlGroupController::deleteAction'
|
_controller: 'Websmid\CustomHtml\Controller\CustomHtmlGroupController::deleteAction'
|
||||||
|
|
||||||
|
customhtmlgroup_toggle:
|
||||||
|
path: ws_customhtml/group/toggle/{idCustomHtmlGroup}
|
||||||
|
methods: [GET, POST]
|
||||||
|
defaults:
|
||||||
|
_controller: 'Websmid\CustomHtml\Controller\CustomHtmlGroupController::toggleAction'
|
||||||
|
|
||||||
customhtmlgroup_update_position:
|
customhtmlgroup_update_position:
|
||||||
path: ws_customhtml/group/update-position
|
path: ws_customhtml/group/update-position
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|||||||
@@ -106,6 +106,27 @@ class CustomHtmlGroupController extends FrameworkBundleAdminController
|
|||||||
return $this->redirectToRoute('customhtmlgroup_index');
|
return $this->redirectToRoute('customhtmlgroup_index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toggleAction(int $idCustomHtmlGroup): RedirectResponse
|
||||||
|
{
|
||||||
|
$group = new CustomHtmlGroup($idCustomHtmlGroup);
|
||||||
|
|
||||||
|
if (!Validate::isLoadedObject($group)) {
|
||||||
|
$this->addFlash('error', $this->trans('Unable to find the group.', 'Modules.Wscustomhtml.Admin'));
|
||||||
|
|
||||||
|
return $this->redirectToRoute('customhtmlgroup_index');
|
||||||
|
}
|
||||||
|
|
||||||
|
$group->active = (int) !$group->active;
|
||||||
|
|
||||||
|
if (!$group->update()) {
|
||||||
|
$this->addFlash('error', $this->trans('An error occurred while updating the status.', 'Admin.Notifications.Error'));
|
||||||
|
} else {
|
||||||
|
$this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success'));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->redirectToRoute('customhtmlgroup_index');
|
||||||
|
}
|
||||||
|
|
||||||
public function updatePositionAction(Request $request): RedirectResponse
|
public function updatePositionAction(Request $request): RedirectResponse
|
||||||
{
|
{
|
||||||
$positionDefinition = $this->get('websmid.customhtml.grid.position.customhtmlgroup_position_definition');
|
$positionDefinition = $this->get('websmid.customhtml.grid.position.customhtmlgroup_position_definition');
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction;
|
|||||||
use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection;
|
use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection;
|
||||||
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn;
|
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn;
|
||||||
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn;
|
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn;
|
||||||
|
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ToggleColumn;
|
||||||
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
|
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
|
||||||
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory;
|
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory;
|
||||||
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\DeleteActionTrait;
|
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\DeleteActionTrait;
|
||||||
@@ -78,9 +79,14 @@ final class CustomHtmlGroupGridDefinitionFactory extends AbstractGridDefinitionF
|
|||||||
->setOptions(['field' => 'blocks_count', 'sortable' => false])
|
->setOptions(['field' => 'blocks_count', 'sortable' => false])
|
||||||
)
|
)
|
||||||
->add(
|
->add(
|
||||||
(new DataColumn('active'))
|
(new ToggleColumn('active'))
|
||||||
->setName($this->trans('Active', [], 'Admin.Global'))
|
->setName($this->trans('Active', [], 'Admin.Global'))
|
||||||
->setOptions(['field' => 'active'])
|
->setOptions([
|
||||||
|
'field' => 'active',
|
||||||
|
'primary_field' => 'id_ws_customhtml_group',
|
||||||
|
'route' => 'customhtmlgroup_toggle',
|
||||||
|
'route_param_name' => 'idCustomHtmlGroup',
|
||||||
|
])
|
||||||
)
|
)
|
||||||
->add(
|
->add(
|
||||||
(new PositionColumn('position'))
|
(new PositionColumn('position'))
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{extends file="module:ws_customhtml/views/templates/hook/_banner.tpl"}
|
||||||
@@ -7,11 +7,11 @@
|
|||||||
{foreach from=$block.slides item="slide" name="slides"}
|
{foreach from=$block.slides item="slide" name="slides"}
|
||||||
{assign var="count" value=$smarty.foreach.slides.iteration|string_format:"%02d"}
|
{assign var="count" value=$smarty.foreach.slides.iteration|string_format:"%02d"}
|
||||||
<div class="swiper-slide">
|
<div class="swiper-slide">
|
||||||
{assign var="customhtmlOverridePath" value="{$smarty.const._PS_THEME_DIR_}modules/ws_customhtml/views/templates/hook/{$hookName}/banner.tpl"}
|
{assign var="customhtmlOverridePath" value="{$smarty.const._PS_THEME_DIR_}modules/ws_customhtml/views/templates/hook/{$hookName}/slide.tpl"}
|
||||||
{if file_exists($customhtmlOverridePath)}
|
{if file_exists($customhtmlOverridePath)}
|
||||||
{include file="module:ws_customhtml/views/templates/hook/`$hookName`/banner.tpl" block=$slide group=$group hookName=$hookName count=$count}
|
{include file="module:ws_customhtml/views/templates/hook/`$hookName`/slide.tpl" block=$slide group=$group hookName=$hookName count=$count}
|
||||||
{else}
|
{else}
|
||||||
{include file="module:ws_customhtml/views/templates/hook/_banner.tpl" block=$slide count=$count}
|
{include file="module:ws_customhtml/views/templates/hook/_slide.tpl" block=$slide count=$count}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
@@ -26,11 +26,11 @@
|
|||||||
{else}
|
{else}
|
||||||
<div class="customhtml-slider-grid-item col">
|
<div class="customhtml-slider-grid-item col">
|
||||||
{/if}
|
{/if}
|
||||||
{assign var="customhtmlOverridePath" value="{$smarty.const._PS_THEME_DIR_}modules/ws_customhtml/views/templates/hook/{$hookName}/banner.tpl"}
|
{assign var="customhtmlOverridePath" value="{$smarty.const._PS_THEME_DIR_}modules/ws_customhtml/views/templates/hook/{$hookName}/slide.tpl"}
|
||||||
{if file_exists($customhtmlOverridePath)}
|
{if file_exists($customhtmlOverridePath)}
|
||||||
{include file="module:ws_customhtml/views/templates/hook/`$hookName`/banner.tpl" block=$slide group=$group hookName=$hookName count=$count}
|
{include file="module:ws_customhtml/views/templates/hook/`$hookName`/slide.tpl" block=$slide group=$group hookName=$hookName count=$count}
|
||||||
{else}
|
{else}
|
||||||
{include file="module:ws_customhtml/views/templates/hook/_banner.tpl" block=$slide count=$count}
|
{include file="module:ws_customhtml/views/templates/hook/_slide.tpl" block=$slide count=$count}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
@@ -44,11 +44,11 @@
|
|||||||
{foreach from=$block.slides item="slide" name="slides"}
|
{foreach from=$block.slides item="slide" name="slides"}
|
||||||
{assign var="count" value=$smarty.foreach.slides.iteration|string_format:"%02d"}
|
{assign var="count" value=$smarty.foreach.slides.iteration|string_format:"%02d"}
|
||||||
<div class="swiper-slide">
|
<div class="swiper-slide">
|
||||||
{assign var="customhtmlOverridePath" value="{$smarty.const._PS_THEME_DIR_}modules/ws_customhtml/views/templates/hook/{$hookName}/banner.tpl"}
|
{assign var="customhtmlOverridePath" value="{$smarty.const._PS_THEME_DIR_}modules/ws_customhtml/views/templates/hook/{$hookName}/slide.tpl"}
|
||||||
{if file_exists($customhtmlOverridePath)}
|
{if file_exists($customhtmlOverridePath)}
|
||||||
{include file="module:ws_customhtml/views/templates/hook/`$hookName`/banner.tpl" block=$slide group=$group hookName=$hookName count=$count}
|
{include file="module:ws_customhtml/views/templates/hook/`$hookName`/slide.tpl" block=$slide group=$group hookName=$hookName count=$count}
|
||||||
{else}
|
{else}
|
||||||
{include file="module:ws_customhtml/views/templates/hook/_banner.tpl" block=$slide count=$count}
|
{include file="module:ws_customhtml/views/templates/hook/_slide.tpl" block=$slide count=$count}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|||||||
Reference in New Issue
Block a user