-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Show remaining maxitems in page module
- Loading branch information
1 parent
d83c159
commit b5bc804
Showing
4 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace IchHabRecht\ContentDefender\ViewHelpers; | ||
|
||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; | ||
|
||
class ExtendPartialViewHelper extends AbstractViewHelper | ||
{ | ||
use CompileWithRenderStatic; | ||
|
||
protected $escapeOutput = false; | ||
|
||
public static function renderStatic( | ||
array $arguments, | ||
\Closure $renderChildrenClosure, | ||
RenderingContextInterface $renderingContext | ||
) { | ||
$packagePath = GeneralUtility::getFileAbsFileName('EXT:content_defender/Resources/Private/'); | ||
$partialPaths = $renderingContext->getTemplatePaths()->getPartialRootPaths(); | ||
$newPartialPaths = array_filter($partialPaths, function ($path) use ($packagePath) { | ||
return strpos($path, $packagePath) === false; | ||
}); | ||
$renderingContext->getTemplatePaths()->setPartialRootPaths($newPartialPaths); | ||
$content = $renderChildrenClosure(); | ||
$renderingContext->getTemplatePaths()->setPartialRootPaths($partialPaths); | ||
|
||
return $content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace IchHabRecht\ContentDefender\ViewHelpers; | ||
|
||
use IchHabRecht\ContentDefender\BackendLayout\BackendLayoutConfiguration; | ||
use TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumn; | ||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
|
||
class MaxitemsViewHelper extends AbstractViewHelper | ||
{ | ||
public function initializeArguments() | ||
{ | ||
parent::initializeArguments(); | ||
|
||
$this->registerArgument('column', 'TYPO3\CMS\Backend\View\BackendLayout\Grid\GridColumn', 'Current column object', true); | ||
} | ||
|
||
public function render() | ||
{ | ||
$maxitems = -1; | ||
|
||
/** @var GridColumn $column */ | ||
$column = $this->arguments['column']; | ||
$pageId = $column->getContext()->getPageId(); | ||
|
||
$backendLayoutConfiguration = BackendLayoutConfiguration::createFromPageId($pageId); | ||
$columnConfiguration = $backendLayoutConfiguration->getConfigurationByColPos($column->getColumnNumber()); | ||
|
||
if (!empty($columnConfiguration['maxitems'])) { | ||
$maxitems = $columnConfiguration['maxitems'] - count($column->getItems()); | ||
} | ||
|
||
return $maxitems; | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" | ||
xmlns:cd="http://typo3.org/ns/IchHabRecht/ContentDefender/ViewHelpers" | ||
data-namespace-typo3-fluid="true"> | ||
<cd:extendPartial> | ||
<style> | ||
.t3-cd-badge-container { | ||
position: relative; | ||
margin-top: 20px | ||
} | ||
|
||
.t3-cd-badge { | ||
position: absolute; | ||
left: 0; | ||
top: 0; | ||
transform: translate(-50%, -50%); | ||
background-color: #ff0000; | ||
z-index: 100; | ||
} | ||
</style> | ||
<div class="t3-cd-badge-container"> | ||
<f:alias map="{maxitems: '{cd:maxitems(column: column)}'}"> | ||
<f:switch expression="{maxitems}"> | ||
<f:case value="-1"></f:case> | ||
<f:case value="1"> | ||
<span class="badge text-bg-warning t3-cd-badge">{maxitems}</span> | ||
</f:case> | ||
<f:case value="0"> | ||
<span class="badge text-bg-danger t3-cd-badge">{maxitems}</span> | ||
</f:case> | ||
<f:defaultCase> | ||
<span class="badge text-bg-success t3-cd-badge">{maxitems}</span> | ||
</f:defaultCase> | ||
</f:switch> | ||
</f:alias> | ||
</div> | ||
<f:render partial="PageLayout/Grid/ColumnHeader" arguments="{_all}" /> | ||
</cd:extendPartial> | ||
</html> |