Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: prefill mailing with data from selected page #63

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions Classes/ViewHelpers/Backend/PageIdViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?php

namespace In2code\Luxletter\ViewHelpers\Backend;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;

/**
* ViewHelper which returns page id in backend modules.
*
* .. note::
* This ViewHelper is experimental!
*
* Examples
* ========
*
* Default::
*
* <luxletter:backend.pageId />
*
* Page id
*/
class PageIdViewHelper extends AbstractBackendViewHelper
{

/**
* This ViewHelper renders no HTML
*
* @var bool
*/
protected $escapeOutput = true;

/**
* Output page id
*
* @return string the page id
*/
public function render(): string
{
return static::renderStatic(
[],
$this->buildRenderChildrenClosure(),
$this->renderingContext
);
}

/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
*
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
): string {
$id = (int)GeneralUtility::_GP('id');
if ($id > 0) {
return '' . $id;
}

return '';
}
}
88 changes: 88 additions & 0 deletions Classes/ViewHelpers/Backend/PageTitleViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?php

namespace In2code\Luxletter\ViewHelpers\Backend;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\ViewHelpers\Be\AbstractBackendViewHelper;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;

/**
* ViewHelper which returns page title in backend modules.
*
* .. note::
* This ViewHelper is experimental!
*
* Examples
* ========
*
* Default::
*
* <luxletter:backend.pageTitle />
*
* Page title
*/
class PageTitleViewHelper extends AbstractBackendViewHelper
{

/**
* This ViewHelper renders no HTML
*
* @var bool
*/
protected $escapeOutput = true;

/**
* Output page title
*
* @return string the page title
*/
public function render(): string
{
return static::renderStatic(
[],
$this->buildRenderChildrenClosure(),
$this->renderingContext
);
}

/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
*
* @return string
*/
public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
): string {
$id = (int)GeneralUtility::_GP('id');
if ($id > 0) {
$pageRecord = BackendUtility::readPageAccess(
$id,
$GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)
);
if ($pageRecord['title']) {
return $pageRecord['title'];
}
}

return '';
}
}
3 changes: 3 additions & 0 deletions Resources/Private/JavaScript/Module.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ define(['jquery'], function($) {
showIfNewsletterIsReady();
}
});
if (input.value.length !== 0) {
input.dispatchEvent(new Event('blur'));
}
}
};

Expand Down
3 changes: 3 additions & 0 deletions Resources/Private/Partials/Newsletter/FormFields.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<f:form.textfield class="form-control input-lg"
property="title"
id="title"
value="{luxletter:backend.pageTitle()}"
placeholder="Newsletter Product A 2020/01"
required="required"/>
<span class="help-block">
Expand Down Expand Up @@ -60,6 +61,7 @@
<f:form.textfield class="form-control input-lg"
property="subject"
id="subject"
value="Newsletter [{luxletter:backend.pageTitle()}]"
placeholder="Your new newsletter for product A (2020/01)"
additionalAttributes="{data-luxletter-testmail:'subject'}"
required="required"/>
Expand Down Expand Up @@ -93,6 +95,7 @@
<f:form.textfield class="form-control input-lg"
property="origin"
id="origin"
value="{luxletter:backend.pageId()}"
placeholder="https://www.yourdomain/newsletter/2020-01/"
additionalAttributes="{data-luxletter-wizardpreviewevent:'newsletter'}"
required="required"/>
Expand Down
1 change: 1 addition & 0 deletions ext_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function () {
'access' => 'user,group',
'icon' => 'EXT:luxletter/Resources/Public/Icons/lux_module_newsletter.svg',
'labels' => 'LLL:EXT:luxletter/Resources/Private/Language/locallang_mod_newsletter.xlf',
'navigationComponentId' => 'TYPO3/CMS/Backend/PageTree/PageTreeElement',
]
);

Expand Down