Skip to content

Commit

Permalink
[TASK] extcode#10 - extract reaser plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lorenz committed Aug 27, 2018
1 parent c441e0e commit f02a0cc
Show file tree
Hide file tree
Showing 13 changed files with 208 additions and 62 deletions.
23 changes: 1 addition & 22 deletions Configuration/FlexForms/ProductsPlugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,24 @@
<numIndex index="0">LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:tx_cartproducts.plugin.products.action.product.show</numIndex>
<numIndex index="1">Product->show</numIndex>
</numIndex>
<numIndex index="2">
<numIndex index="0">LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:tx_cartproducts.plugin.products.action.product.teaser</numIndex>
<numIndex index="1">Product->teaser</numIndex>
</numIndex>
</items>
</config>
</TCEforms>
</switchableControllerActions>

<!-- Template Layout -->
<settings.templateLayout>
<TCEforms>
<label>LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:flexforms_template.templateLayout</label>
<displayCond>FIELD:switchableControllerActions:=:Product->show;Product->list</displayCond>
<config>
<type>select</type>
<itemsProcFunc>Extcode\Cart\Hooks\ItemsProcFunc->user_templateLayout</itemsProcFunc>
<itemsProcFuncConf>Products</itemsProcFuncConf>
<renderType>selectSingle</renderType>
</config>
</TCEforms>
</settings.templateLayout>

<!-- order -->
<settings.orderBy>
<TCEforms>
<label>LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:tx_cartproducts.plugin.products.action.product.list.orderBy</label>
Expand Down Expand Up @@ -77,7 +72,6 @@
</TCEforms>
</settings.orderBy>

<!-- order direction -->
<settings.orderDirection>
<TCEforms>
<label>LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:tx_cartproducts.plugin.products.action.product.list.orderDirection</label>
Expand Down Expand Up @@ -124,21 +118,6 @@
</TCEforms>
</settings.showPageUids>

<settings.productUids>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:tx_cartproducts.plugin.products.action.product.teaser.select.product</label>
<displayCond>FIELD:switchableControllerActions:=:Product->teaser</displayCond>
<config>
<type>select</type>
<foreign_table>tx_cartproducts_domain_model_product_product</foreign_table>
<size>3</size>
<minitems>1</minitems>
<maxitems>99</maxitems>
</config>
</TCEforms>
</settings.productUids>

<settings.categoriesList>
<TCEforms>
<exclude>1</exclude>
Expand Down
60 changes: 60 additions & 0 deletions Configuration/FlexForms/TeaserProductsPlugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<T3DataStructure>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>Optionen</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<settings.templateLayout>
<TCEforms>
<label>LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:flexforms_template.templateLayout</label>
<config>
<type>select</type>
<itemsProcFunc>Extcode\Cart\Hooks\ItemsProcFunc->user_templateLayout</itemsProcFunc>
<itemsProcFuncConf>TeaserProducts</itemsProcFuncConf>
<renderType>selectSingle</renderType>
</config>
</TCEforms>
</settings.templateLayout>

<settings.showPageUids>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:tx_cartproducts.plugin.products.action.product.list.select.show_pid</label>
<config>
<type>group</type>
<internal_type>db</internal_type>
<allowed>pages</allowed>
<size>1</size>
<maxitems>1</maxitems>
<minitems>0</minitems>
<show_thumbs>1</show_thumbs>
<wizards>
<suggest>
<type>suggest</type>
</suggest>
</wizards>
</config>
</TCEforms>
</settings.showPageUids>

<settings.productUids>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:tx_cartproducts.plugin.products.action.product.teaser.select.product</label>
<config>
<type>select</type>
<foreign_table>tx_cartproducts_domain_model_product_product</foreign_table>
<size>3</size>
<minitems>1</minitems>
<maxitems>99</maxitems>
</config>
</TCEforms>
</settings.productUids>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>
11 changes: 8 additions & 3 deletions Resources/Private/Language/de.locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
<trans-unit id="flexforms_template.templateLayout">
<source>Template Layout</source>
</trans-unit>
<trans-unit id="flexforms_template.templateLayout.table">
<trans-unit id="flexforms_template.templateLayout.products.table">
<source>Table</source>
<target>Tabelle</target>
</trans-unit>
<trans-unit id="flexforms_template.templateLayout.grid">
<trans-unit id="flexforms_template.templateLayout.products.grid">
<source>Grid</source>
</trans-unit>

Expand Down Expand Up @@ -129,8 +129,13 @@
<target>Teaserprodukt auswählen</target>
</trans-unit>

<trans-unit id="tx_cartproducts.plugin.teaser_products.title">
<source>CartProducts: Products (Teaser)</source>
<target>CartProducts: Produkte (Teaser)</target>
</trans-unit>

<trans-unit id="tx_cartproducts.plugin.single_product.title">
<source>CartProducts: Single Produkt</source>
<source>CartProducts: Single Product</source>
<target>CartProducts: Einzelprodukt</target>
</trans-unit>

Expand Down
10 changes: 7 additions & 3 deletions Resources/Private/Language/locallang_be.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
<trans-unit id="flexforms_template.templateLayout">
<source>Template Layout</source>
</trans-unit>
<trans-unit id="flexforms_template.templateLayout.table">
<trans-unit id="flexforms_template.templateLayout.products.table">
<source>Table</source>
</trans-unit>
<trans-unit id="flexforms_template.templateLayout.grid">
<trans-unit id="flexforms_template.templateLayout.products.grid">
<source>Grid</source>
</trans-unit>

Expand Down Expand Up @@ -106,8 +106,12 @@
<source>Choose teaser product</source>
</trans-unit>

<trans-unit id="tx_cartproducts.plugin.teaser_products.title">
<source>CartProducts: Products (Teaser)</source>
</trans-unit>

<trans-unit id="tx_cartproducts.plugin.single_product.title">
<source>CartProducts: Single Produkt</source>
<source>CartProducts: Single Product</source>
</trans-unit>

<trans-unit id="pages.doktype.182">
Expand Down
2 changes: 1 addition & 1 deletion Resources/Private/Layouts/Default.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">

<div class="tx-cart">
<div class="tx-cart-products">
<f:render section="main"/>
</div>
</html>
49 changes: 49 additions & 0 deletions Resources/Private/Partials/Product/Teaser/Grid.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:cartproducts="http://typo3.org/ns/Extcode/CartProducts/ViewHelpers"
data-namespace-typo3-fluid="true">

<f:section name="GridItem">
<div class="col-md-4">
<f:if condition="{product.images}">
<cartproducts:link.product pluginName="Products" product="{product}"settings="{settings}">
<f:image src="{product.firstImage.originalResource.originalFile.uid}"
title="{product.firstImage.originalResource.title}"
alt="{product.firstImage.originalResource.title}"
width="{settings.listAction.media.image.size.small.maxWidth}"
height="{settings.listAction.media.image.size.small.maxHeight}" />
</cartproducts:link.product>
</f:if>
<cartproducts:link.product pluginName="Products" product="{product}"settings="{settings}">
{product.title}
</cartproducts:link.product>
<f:render partial="Product/Price" arguments="{product: product, settings: settings, currencyTranslationData:currencyTranslationData}"></f:render>
</div>
</f:section>

<f:for each="{products}" as="product" iteration="iterator">
<f:if condition="{iterator.isFirst}">
<div class="row">
</f:if>

<f:if condition="{iterator.cycle} % 3">
<f:then>
<f:render section="GridItem" arguments="{_all}"/>
</f:then>

<f:else>
<f:render section="GridItem" arguments="{_all}"/>

<f:if condition="{iterator.isLast}">
<f:then></f:then>
<f:else>
</div><div class="row">
</f:else>
</f:if>
</f:else>
</f:if>

<f:if condition="{iterator.isLast}">
</div>
</f:if>
</f:for>
</html>
45 changes: 45 additions & 0 deletions Resources/Private/Partials/Product/Teaser/Table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:cartproducts="http://typo3.org/ns/Extcode/CartProducts/ViewHelpers"
data-namespace-typo3-fluid="true">

<table class="table table-striped table-hover">
<thead>
<tr>
<th class="col-md-2">
&nbsp;
</th>
<th class="col-md-6">
<f:translate key="tx_cartproducts_domain_model_product_product.title"/>
</th>
<th class="col-md-4">
<f:translate key="tx_cartproducts_domain_model_product_product.price"/>
</th>
</tr>
</thead>
<tbody>
<f:for each="{products}" as="product">
<tr>
<td>
<f:if condition="{product.images}">
<cartproducts:link.product pluginName="Products" product="{product}"settings="{settings}">
<f:image src="{product.firstImage.originalResource.originalFile.uid}"
title="{product.firstImage.originalResource.title}"
alt="{product.firstImage.originalResource.title}"
width="{settings.listAction.media.image.size.small.maxWidth}"
height="{settings.listAction.media.image.size.small.maxHeight}" />
</cartproducts:link.product>
</f:if>
</td>
<td>
<cartproducts:link.product pluginName="Products" product="{product}"settings="{settings}">
{product.title}
</cartproducts:link.product>
</td>
<td>
<f:render partial="Product/Price" arguments="{product: product, settings: settings, currencyTranslationData:currencyTranslationData}"></f:render>
</td>
</tr>
</f:for>
</tbody>
</table>
</html>
8 changes: 5 additions & 3 deletions Resources/Private/Templates/Product/List.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">

<div class="product">
<f:render partial="Product/List{f:format.case(value: settings.templateLayout, mode: 'capital')}" arguments="{_all}" />
</div>
<f:layout name="Default"/>

<f:section name="main">
<f:render partial="Product/List/{f:format.case(value: settings.templateLayout, mode: 'capital')}" arguments="{_all}" />
</f:section>
</html>
20 changes: 1 addition & 19 deletions Resources/Private/Templates/Product/Teaser.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,6 @@
<f:layout name="Default"/>

<f:section name="main">
<f:if condition="{products}">
<f:for each="{products}" as="product">
<h3>{product.title}</h3>

<f:if condition="{product.firstImage}">
<f:image src="{product.firstImage.originalResource.originalFile.uid}"
title="{product.firstImage.originalResource.title}"
alt="{product.firstImage.originalResource.title}"
width="{settings.teaserAction.media.image.size.medium.maxWidth}"
height="{settings.teaserAction.media.image.size.medium.maxHeight}"/>
</f:if>

<div>{product.teaser -> f:format.html()}</div>

<f:if condition="{settings.cart.pid}">
<f:render partial="Product/CartForm" arguments="{product: product, pid: settings.cart.pid}"/>
</f:if>
</f:for>
</f:if>
<f:render partial="Product/Teaser/{f:format.case(value: settings.templateLayout, mode: 'capital')}" arguments="{_all}" />
</f:section>
</html>
19 changes: 17 additions & 2 deletions ext_localconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

defined('TYPO3_MODE') or die();

$_LLL_be = 'LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf';

// configure plugins

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
Expand All @@ -15,6 +17,17 @@
]
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Extcode.' . $_EXTKEY,
'TeaserProducts',
[
'Product' => 'teaser, showForm',
],
[
'Product' => 'showForm',
]
);

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'Extcode.' . $_EXTKEY,
'SingleProduct',
Expand Down Expand Up @@ -114,5 +127,7 @@
= 'Extcode\\CartProducts\\ViewHelpers';

// register listTemplateLayouts
$GLOBALS['TYPO3_CONF_VARS']['EXT'][$_EXTKEY]['templateLayouts'][] = ['LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:flexforms_template.templateLayout.table', 'table'];
$GLOBALS['TYPO3_CONF_VARS']['EXT'][$_EXTKEY]['templateLayouts'][] = ['LLL:EXT:cart_products/Resources/Private/Language/locallang_be.xlf:flexforms_template.templateLayout.grid', 'grid'];
$GLOBALS['TYPO3_CONF_VARS']['EXT'][$_EXTKEY]['templateLayouts']['products'][] = [$_LLL_be . ':flexforms_template.templateLayout.products.table', 'table'];
$GLOBALS['TYPO3_CONF_VARS']['EXT'][$_EXTKEY]['templateLayouts']['products'][] = [$_LLL_be . ':flexforms_template.templateLayout.products.grid', 'grid'];
$GLOBALS['TYPO3_CONF_VARS']['EXT'][$_EXTKEY]['templateLayouts']['teaser_products'][] = [$_LLL_be . ':flexforms_template.templateLayout.products.table', 'table'];
$GLOBALS['TYPO3_CONF_VARS']['EXT'][$_EXTKEY]['templateLayouts']['teaser_products'][] = [$_LLL_be . ':flexforms_template.templateLayout.products.grid', 'grid'];
Loading

0 comments on commit f02a0cc

Please sign in to comment.