Skip to content

Commit

Permalink
[FEATURE] Add MenuSubpages ViewHelper & FE Template
Browse files Browse the repository at this point in the history
  • Loading branch information
filippos-gmk committed Apr 12, 2024
1 parent 4a647ea commit cecb7c2
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 3 deletions.
59 changes: 59 additions & 0 deletions local_packages/psi/Classes/ViewHelpers/SubpagesViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Jacuzzi\Psi\ViewHelpers;

use TYPO3\CMS\Core\Database\Connection;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
class SubpagesViewHelper extends AbstractViewHelper
{

use CompileWithRenderStatic;

/**
* Initialize arguments
*/
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('uid', 'int', 'the UID of the Page to Look for Subpages', true);
}

/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
): array {

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('pages');
$resultsArray = [];
$id = (int)$arguments['uid'];

$results = $queryBuilder
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq(
'pid',
$queryBuilder->createNamedParameter($id, Connection::PARAM_INT)
)
)
->executeQuery();

while ($row = $results->fetchAssociative()) {
array_push($resultsArray, $row);
}
return $resultsArray;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
<source>Download</source>
<target>Descargar</target>
</trans-unit>
<trans-unit id="news-readmore" resname="news-readmore">
<source>Read more</source>
<target>Sigue leyendo</target>
</trans-unit>
</body>
</file>
</xliff>
3 changes: 3 additions & 0 deletions local_packages/psi/Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
<trans-unit id="download-button" resname="download-button">
<source>Download</source>
</trans-unit>
<trans-unit id="news-readmore" resname="news-readmore">
<source>Read more</source>
</trans-unit>
</body>
</file>
</xliff>
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
{data.header}
{namespace uzi=Jacuzzi\Psi\ViewHelpers}
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true">
<f:variable name="subpages"><uzi:subpages uid="{data.pages}"/></f:variable>
<f:if condition="{subpages}">
<f:then>
<div class="latestnews-container">
<div class="latestnews-inner">
<ul class="latestnews-wrap">
<f:for as="page" each="{subpages}">
<li class="latestnews-single profile__card">
<div class="latestnews-single-header">
<f:if condition="{page.eventdatetime}">
<f:then>
<p><f:format.date format="d.m.Y" date="{page.eventdatetime}"></f:format.date></p>
</f:then>
</f:if>
<f:if condition="{page.location}">
<f:then>
<p>{page.location}</p>
</f:then>
</f:if>
</div>
<h4 class="latestnews-single-title">
{page.title}
</h4>
<f:link.page class="latestnews-single-link" pageUid="{page.uid}">
<f:translate key="news-readmore" extensionName="psi"/>
<svg class="svg-icon" style="vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg">
<path d="M640 768c-12.8 0-21.333333-4.266667-29.866667-12.8-17.066667-17.066667-17.066667-42.666667 0-59.733333l213.333333-213.333333c17.066667-17.066667 42.666667-17.066667 59.733333 0s17.066667 42.666667 0 59.733333l-213.333333 213.333333C661.333333 763.733333 652.8 768 640 768z" />
<path d="M853.333333 554.666667c-12.8 0-21.333333-4.266667-29.866667-12.8l-213.333333-213.333333c-17.066667-17.066667-17.066667-42.666667 0-59.733333s42.666667-17.066667 59.733333 0l213.333333 213.333333c17.066667 17.066667 17.066667 42.666667 0 59.733333C874.666667 550.4 866.133333 554.666667 853.333333 554.666667z" />
<path d="M853.333333 554.666667 170.666667 554.666667c-25.6 0-42.666667-17.066667-42.666667-42.666667s17.066667-42.666667 42.666667-42.666667l682.666667 0c25.6 0 42.666667 17.066667 42.666667 42.666667S878.933333 554.666667 853.333333 554.666667z" />
</svg>
</f:link.page>
</li>
</f:for>
</ul>
</div>
</div>
</f:then>
</f:if>
</html>
35 changes: 33 additions & 2 deletions local_packages/psi/Resources/Public/Css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ h5 {
}

.profile__image {
object-fit: cover;
width: 200px;
height: 200px;
}
Expand Down Expand Up @@ -921,19 +922,39 @@ h5 {
padding: 30px;
}

.downloads-wrap {
.latestnews-inner {
padding: 30px 0;
}

.downloads-wrap,
.latestnews-wrap {
align-items: center;
display: flex;
gap: 25px;
}

.downloads-single {
.downloads-single,
.latestnews-single {
background-color: #FFF;
display: block;
flex: 0 1 calc(100% / 2 - 25px);
max-width: calc(100% / 2 - 25px);
}

.latestnews-single-link {
align-items: center;
color: #000;
display: flex;
gap: 5px;
font-size: 18px;
font-weight: 700;
text-decoration: none;
}

.latestnews-single-link svg {
max-width: 24px;
}

.downloads-single p {
margin-bottom: 10px;
}
Expand All @@ -953,3 +974,13 @@ h5 {
.download-cta {
line-height: 24px;
}

.latestnews-single-header {
align-items: center;
display: flex;
gap: 15px;
}

.latestnews-single-title {
padding: 15px 0;
}

0 comments on commit cecb7c2

Please sign in to comment.