[Neos] Widget vs Plugin with pluginView

Mark Kuiphuis mark at capesso.com.au
Fri May 22 04:24:01 CEST 2015


Hi all,

I have been googling the world wide web for quite a while now, but 
unfortunately I am not able to find a solution for my problem. I have 
two main issues related to the same Shop package.

I have created a Shop package with a basket, promo code, checkout 
process, catalog (with 1 product) and payment integration with a Payment 
Gateway.

This package is a Neos Plugin and the whole checkout process works fine. 
 From the page with the PluginView "Catalog" I can add the product to 
the basket and from there on I can go to the Checkout process.

What I would like to achieve is that the site owner can add a 
"ProductTeaser" on every page he would like to do so. This teaser 
product retrieves the product from the Vendor.Shop ProductRepository and 
does display the name, image, price and a "Buy Now" button, which, upon 
clicking, should add a quantity of 1 to the basket. The form I use is 
very straightforward:

<f:form action="addToBasket" name="product" controller="Basket" 
package="Vendor.Shop" subpackage="Shop">
	<f:form.hidden name="product" value="{product.identifier}" />
	<f:form.hidden name="quantity" value="1" />
	<div class="buyNow">
		<f:form.submit value="{f:translate(id:'link.buyNow', source: 
'Basket')}" class="shop-button" />
	</div>
</f:form>

However, when this element is loaded via Neos, the URL of the form 
action remains on the same page..

<form name="product" action="/current-page?--vendor-shop-........">

How can I change this so that the action is being called on the page 
where the basket "PluginView" is located like below (so regardless on 
which page the visitor sees this teaser)

<form name="product" action="/shop/shopping-cart?--vendor-shop-........">

Because at the end of the "addToBasketAction" I am redirecting to the 
viewAction of the same Basket controller to display the basket.

I have found out that using a PluginView in the NodeTypes.yaml of the 
shop package will make sure that the URL of the form action has been set 
correctly, but not when the product teaser is included via a ViewHelper. 
The "PluginView" option also only allows you to use that PluginView 
once. But I don't know on how many pages the shop owner would like to 
place this Product Teaser.

The other problem I am facing is that next to the main menu, on every 
page, should be a "Buy Now" button as well. Because I would like it to 
appear on every page, I thought the best option would be to include the 
button in the Root.ts2 (and NodeTypes.yaml), with the following code:

### NodeTypes.yaml ###
'Vendor.Shop:Plugin':
   superTypes: ['TYPO3.Neos:Plugin']
   ui:
     label: ' Vendor Shop'
     group: 'plugins'
   options:
     pluginViews:
       'BuyNowButton':
         label: 'BuyNow'
         controllerActions:
           'Vendor\Shop\Shop\Controller\BasketController': [buyNow']

### Root.ts2 ###
page.body.parts.buyNow = Vendor.Shop:Plugin

But this does not set the URL of the form action correctly :(

Is there any other way to achieve this?

Thanks in advance,

Mark Kuiphuis


More information about the Neos mailing list