I have a doubt with powermail 2.x extension .
My actual requirement is , I have a form (custom extension) through which I can search some places using zip code. So once user submits the value (eg zip code) , the webiste will be redirected to page where I list all available places under that zip code as link. When a user clicks on that link , Website will be redirected to another page where I hvae configured powermail 2.x extension . What I want to implement is , based on link clicked (I will be passing place_id through the link and each place have some membership types).I want to show a set of membership types in radio buttons(Fetched from another table using the arguments from url). and this items should be there in preview and mail as well.
The same thing we can implement using $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['powermail']['PM_FieldHook'] in powermail 1.6 ?
How we can implement the same in powermail 2.x??
Any help would be appropriated ?
Finally I have managed to fix it by myself.
All you have to do is,
Add a new check box field in the powermial form , In the extended tab , you can assign a typoscript variable something like lib.products .
lib.products = CONTENT
lib.products {
table = pages
select {
pidInList = xxx
}
renderObj = COA
renderObj {
10 = COA
10 {
10 = TEXT
10.dataWrap = {field:title}[\n]
}
}
}
Above code will generate dynamic radio buttons in the frontend.Again if you wish to like create custom field type in powermail field.
tx_powermail.flexForm.type.addFieldOptions.new = Name of the field
tx_powermail.flexForm.type.addFieldOptions.new.dataType = 1 (If it is an array)
After that add the below typoscript code
plugin.tx_powermail.view {
partialRootPath >
partialRootPaths {
10 = EXT:powermail/Resources/Private/Partials/
20 = EXT:extension/Resources/Private/Partials/
}
}
and create a template fileEXT:extension/Resources/Private/Partials/New.html.In that file , you can include field(checkboxes radio buttons or selectboxes).
After that
$signalSlotDispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Extbase\SignalSlot\Dispatcher');
$signalSlotDispatcher->connect(
'In2code\Powermail\Controller\FormController',
'formActionBeforeRenderView',
'HEV\Extension\Controller\FormController',
'customfucntion',
FALSE
);
we have to implement the signal slot available in powermail 2.X
and in the the
/**
* #param \In2code\Powermail\Domain\Model\Form $form
* #param \In2code\Powermail\Controller\FormController $pObj
*/
public function manipulateMailObjectOnCreate($form, $pObj) {
$sectionNr = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP("SID");
if ( !isset( $sectionNr ))
return ;
foreach ( $form as $forms ){
foreach( $forms->getPages() as $key => $pages){
foreach ( $pages->getFields() as $fields ){
switch ( $fields->getType() ){
case "new":
$fields->setMandatory(TRUE);
$fields->setCreateFromTyposcript('lib.products');
break;
}
}
}
}
}
Related
I’m looking for a way to get all checked checkbox-values from a field in a powermail form. I can access single values from the array in my typoscript template with
data = GP:tx_powermail_pi1|field|marker|index.
Is there a way to interate over the array when I don't know the number of checkboxes (dynamically filled) or to serialize the array? I am not experienced with typoscript or powermail but allready tried to find a solution for quite some time.
What i am trying to achieve ist to have a multiselect field for people to send the mail to that gets populated from fe_users.
The relevant code from the typoscript template that overwrites the receiver is:
plugin.tx_powermail {
settings {
setup {
receiver {
enable = {$plugin.tx_powermail.settings.receiver.enable}
overwrite {
email = COA
email {
10 = CONTENT
10 {
table = fe_users
select {
pidInList = 8689
where {
# UID of the fe_users record is given in field with marker {fragegehtan}
data = GP:tx_powermail_pi1|field|fragegehtan|0
wrap = uid=|
intval = 1
}
}
renderObj = COA
renderObj {
10 = TEXT
10.field = email
stdWrap.wrap = |,
}
}
}
}
}
}
}
}
This is supposed to create a comma separated list of uids of all selected fe_users. Ist there any advice how to do it?
I'm trying to extend the fluid_styled_content element "Menu". Within my partial (e.g. typo3conf/ext/my_theme/Resources/Private/Templates/Content/Partials/Menu/Type-1.html I need to access the page properties of the page where the menu CE resides. How can I archive this? {data} contains only the data of the content element.
In {data.pid} you have the uid of the page.
You can use a viewhelper to get the complete pages record (in ext:vhs there is a viewhelper to get any kind of records).
or you can use <f:cObject> and some typoscript to access single values.
Use \TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor.
I cannot check the code right now but you could take this as a starting point:
tt_content.menu.dataProcessing {
30 = \TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
30 {
table = pages
where.dataWrap = uid = {TSFE:id}
as = page
}
}
Afterwards you can access the current page‘s properties via {page.0.property}.
There‘s just one query for each menu content object with this approach while most view helper solutions tend to increase the number of database queries issued.
#undko: The DatabaseQueryProcessor was the perfect hint. But your snippet had two problems I had to fix:
- the TypoScript code needs pidInList to work
- in the Fluid Template there was data missing: pageproperties.0.data.myproperty
Here is my final code that works fine for me:
tt_content.menu.dataProcessing {
30 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
30 {
table = pages
where.dataWrap = uid = {TSFE:id}
pidInList = 1
as = pageproperties
}
}
In the Fluid template I use {pageproperties.0.data.tx_mytheme_fieldname}.
I don't know why exactly but I can't access page properties with the proposed solution. I'm using Typo3 10.4.9.
I found an alternative solution :
tt_content.menu dataProcessing {
30 = TYPO3\CMS\Frontend\DataProcessing\DatabaseQueryProcessor
30 {
table = pages
pidInList = 0
recursive = 99
uidInList = this
as = pageproperties
}
}
Maybe this will help someone else.
More brutal approach; to access the page properties everywhere, for example in a custom content element. Create in the sitepackage Classes/ViewHelper/GetPagePropertiesViewHelper.php :
<?php namespace Xxx\Sitepackage\ViewHelpers;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
class GetPagePropertiesViewHelper extends \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper
{
public function initializeArguments()
{
$this->registerArgument('pid', 'int', 'The page uid to get the pageproperties from', true, 1);
$this->registerArgument('property', 'string', 'A specific page property to be returned', false, null);
}
public function render()
{
$connectionPool = GeneralUtility::makeInstance(ConnectionPool::class);
$queryBuilder = $connectionPool->getQueryBuilderForTable('pages');
$pageProperties = [];
$statement = $queryBuilder
->select('*')
->from('pages')
->where(
$queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($this->arguments['pid'], \PDO::PARAM_INT))
)
->execute();
while ($row = $statement->fetch()) {
$pageProperties[] = $row;
}
if ($property) {
return $pageProperties[0][$property];
}
return $pageProperties[0];
}
}
Usage in a template or partial:
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:c="http://typo3.org/ns/Xxx/Sitepackage/ViewHelpers"
data-namespace-typo3-fluid="true">
<c:getPageProperties pid="{data.pid}" property="description"/>
<f:debug><c:getPageProperties pid="{data.pid}"/></f:debug>
I'm trying to change the browser page title when in single view of my extbase extension. All my attempts failed:
/**
* action show
*
* #param \Vendor\Abc\Domain\Model\Abc $record
* #return void
*/
public function showAction(\Vendor\Abc\Domain\Model\Abc $record) {
$this->view->assign('record', $record);
//$GLOBALS['TSFE']->page['title'] = $record->getAbc();
//$GLOBALS['TSFE']->indexedDocTitle = $record->getAbc();
//$GLOBALS['TSFE']->page['title'] = $record;
//$GLOBALS['TSFE']->indexedDocTitle = $record;
//$GLOBALS['TSFE']->additionalHeaderData['CustomUserIntTitle']
//= '<title>' . $this->getAbc($record) . '</title>';
//$myNewTitle = 'Title';
//$title = '<title>' . $myNewTitle . '</title>';
//$this->response->addAdditionalHeaderData($title);
//$GLOBALS['TSFE']->content = preg_replace('#<title>.*<\/title>#', '<title>' . $record->getTitle() . '</title>', $GLOBALS['TSFE']->content);
//$this->response->addAdditionalHeaderData('<title>Mein eigener Title</title>');
}
I registred the action as non-cacheable (not sure if I really have to though)
If TYPO3 >= 9 LTS follow:
https://stackoverflow.com/a/63745294/4533462
For TYPO3 <= 8 LTS you can do it like this
The solution of Jan is a regular way of changing the depending on GET Params or Page ID.
As you tried to change the title inside the controller is depending on how the page title is set in the Typoscript. However, changing the title inside the controller is possible using the PageRenderer:
$this->objectManager->get(\TYPO3\CMS\Core\Page\PageRenderer::class)->setTitle('My title');
// For the search
$GLOBALS['TSFE']->indexedDocTitle = 'My title';
If it is not working with PageRenderer, you must have a special configuration for your page title in Typoscript or other extensions override the title.
In TYPO3 9-10 new logic. The last answer doesn't work for me so I used this
https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/PageTitleApi/Index.html
First. Create your own Title provider. path 'ext/Classes/PageTitle/MyRecordTitleProvider.php'
<?php
namespace Vendor\Ext\PageTitle;
use TYPO3\CMS\Core\PageTitle\AbstractPageTitleProvider;
class MyRecordTitleProvider extends AbstractPageTitleProvider
{
/**
* #param string $title
*/
public function setTitle(string $title)
{
$this->title = $title;
}
}
Second. In your TypoScript Setup pageTitleProviders. The main idea that classes override each other and you can set up the order (priority). Like that
config.pageTitleProviders.myext {
provider = Vendor\Ext\PageTitle\MyRecordTitleProvider
before = altPageTitle,record,seo
}
}
Expl. First, check the normal page title and all normal setup like
config{
pageTitleFirst = 1
pageTitleSeparator = |
pageTitleSeparator.noTrimWrap = | | |
}
Will make all page titles like that "Page title | Website title"
'Website title' will be taken from Sites -> websiteTitle
Then In priority our next Provider, Will override the normal page title. Like "Ext title | Website title"
Last in our settings seo_title override.
Now all ready for our title setup in ExtBase controller. We need just add in showAction
$GLOBALS['TSFE']->indexedDocTitle = $title;
$titleProvider = GeneralUtility::makeInstance(MyRecordTitleProvider::class);
$titleProvider->setTitle($title);
Try with TS (sample is from Georg Ringers excellent ext:news):
[globalVar = TSFE:id = NEWS-DETAIL-PAGE-ID]
config.noPageTitle = 2
temp.newsTitle = RECORDS
temp.newsTitle {
dontCheckPid = 1
tables = tx_news_domain_model_news
source.data = GP:tx_news_pi1|news
source.intval = 1
conf.tx_news_domain_model_news = TEXT
conf.tx_news_domain_model_news {
field = title
htmlSpecialChars = 1
}
wrap = <title>|</title>
}
page.headerData.1 >
page.headerData.1 < temp.newsTitle
[global]
you just need to make some changes accordingly to your extension
I am working with the TYPO3 Solr extension and I have some doubts regarding the solr result set manipulation.
I have added a special configuration for indexing some particular pages in my page tree. ie Pages that starts with the label "Expertise%" .I have managed to added this successfully . And the indexing is working successfully with our any trouble. But what I would like to achieve is that , I want to added parent page title to the search result.i.e
This is the page tree
|---- 1.00.100 (parent page)
|--Subpage 1
|--Subpage 2
|--Expertise
|--Test page`
And in the solr search result should be
1.00.100 - Expertise
Is this possible in TYPO3 Solr. Is there any hook or signalslot available to implement this?
Tried this ,But doesn't seems to work for me ?
plugin.tx_solr.index.queue.expertise_offered = 1
plugin.tx_solr.index.queue.expertise_offered {
table = pages
additionalWhereClause = doktype = 1 AND no_search = 0 AND title LIKE '%Expertise offered%'
fields {
title = title
content = CONTENT
parentPageTitle_stringS = CONTENT
parentPageTitle_stringS {
table = pages
select {
selectFields = title
where = uid = ###pid###
}
markers {
pid.data = field:pid
}
}
content {
table = tt_content
select {
selectFields = header, bodytext
}
renderObj = COA
renderObj {
10 = TEXT
10.field = header
# This removes HTML tags
11 = SOLR_CONTENT
11.field = bodytext
}
}
url = TEXT
url.typolink.parameter = TEXT
url.typolink.parameter.field = uid
}
}
You probably don't need any hook or signal-slot. You can do it as follows:
Add the title of the parent page to your indexing configuration. There is no field for it, but you can dynamically add fields to SOLR documents. This is done by sending the data in a field which has a certain suffix, which determines the field type.
For example: Setting the field parentPageTitle_stringS to the parent pages title in the indexing configuration creates a new stored, single-valued field of type string in the indexed document.
Filling this field could look like this:
plugin.tx_solr {
index {
queue {
<yourindexconfigname> = 1
<yourindexconfigname> {
table = pages
fields {
parentPageTitle_stringS = CONTENT
parentPageTitle_stringS {
# Build a query here to retrieve
# the parent page title.
}
}
}
}
}
}
In your template for search results, you can use the marker ###RESULT_DOCUMENT.parentPageTitle_stringS### to retrieve the field.
The available field types can be found in EXT:solr/Resources/Solr/typo3cores/conf/general_schema_fields.conf from line 157 onwards (refering to version 3.0.0 here).
You should of course use a type other than string if you want to have the result indexed nicely.
I have two forms in powermail 1.6 and want to change the form action according to the form uid.
I have the following code:
plugin.tx_powermail_pi1 {
formaction >
formaction = TEXT
formaction {
typolink {
parameter = 280
parameter.if {
equals.field = uid
value = 1618
}
...
}
}
}
The code is working - if the id of the form is 1618, then the form action leads to the page with the id 280.
But how can I make an Else statement to change the form action for another form id e.g. 1612 to page id 290?
You have to do it in a COA
formaction = COA
formaction.10 = TEXT
formaction.20 = TEXT
The .10 will handle the true condition.
The .20 will handle the else condition