I'm trying to send a Newsletter with tx_news and direct_mail.
The HTML rendering is fine, but I have problems with the plain text and the documentation handles only tt_news.
How do I get the plaintext of tx_news?
Addendum: I only have a Template for the HTML rendering and a Template for the plaintext - the plaintext template is empty yet. I have integrated the template via TypoScript.
plugin.tx_directmail_pi1 {
siteUrl = http://my.domain.com/
}
tx_directmail_pi1.10 = TEMPLATE
tx_directmail_pi1.10 {
template = FILE
template.file = EXT:my_extension/Resources/Private/Layouts/Page/Newsletter.tmpl
}
I propose the following solution: Use a different template for plaintext. This is described in the manual at https://docs.typo3.org/typo3cms/extensions/news/AdministratorManual/Templates/Start/Index.html and afterwards use one of those scripts to transform HTML to plaintext. I found https://github.com/mtibben/html2text and https://github.com/soundasleep/html2text or search yourself for "plaintext html to text".
The reason is simple: there is no transformation available in news or the TYPO3 core which transforms the bodytext with its links to plain text.
Related
The finishers EmailToSender and EmailToReceiver both give the format option 'html' OR 'plaintext'. How can I send emails with both, 'plaintext' AND 'html'?
The background is: AFAIK emails should always contain a defined plaintext part for those of us who are not able or do not wish to receive HTML emails. AFAIK this is required by RFC (don't know which one).
This feature was added to TYPO3v10: Send plaintext and HTML mails in EmailFinisher
As I never work much with the form-extension I don't know exactly if you're right about the mail-format, specifically that html-format never includes a text-only-part. I'd advise to check that the mail-format is really html and not multipart.
If required you can add an own finisher, also as option in the Backend selection.
In this documentation are many things described what is possible:
add own finisher class(es)
exchange data between different finishers
localize (translate) finishers
define default values
use the context of finishers
add the finisher to the UI of the backend
As first step I'd try to program a simple finisher, it can do some simple thing like adding "Hello World" to the mail or replacing the mail-text completely.
In this class I'd try to access data from other finishers and test if these data are programatically available even without activating the other finishers by choice in backend. If that's possible you could retrieve data from the two finishers for text- and html-mail and combine them according to your need.
To add a bit code here, this is how a simple finisher is included:
TYPO3:
CMS:
Form:
prototypes:
standard:
finishersDefinition:
CustomFinisher:
implementationClassName: 'VENDOR\MySitePackage\Domain\Finishers\CustomFinisher'
and this is a simple finisher-class:
declare(strict_types = 1);
namespace VENDOR\MySitePackage\Domain\Finishers;
class CustomFinisher extends \TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher
{
protected $defaultOptions = [
'yourCustomOption' => 'Olli',
];
// ...
}
Further details you have to read in the documentation or ask more detailed.
new here, and also new to TYPO3.
I need to put something like [imagebox, title='box1'] into content editor and that will be replaced by a text and image with some javascript effect (text and image are managed in the DB elsewhere, the tag is just for the placement in the page).
I've read that TYPO3 has a mechanism for adding custom tags and I managed to make them accepted in the RTE.
I tried instead of [imagebox..... to use
<imagebox>box1</imagebox>
with something like this (copied from web):
tt_content.text.20.parseFunc.tags {
imagebox < lib.parseFunc.tags.link
imagebox = TEXT
imagebox.value= replaced
# imagebox = PHP_SCRIPT
# imagebox {
# stripNL = 0
# Pass a parameter from Typoscript to a PHP script:
# UID of the page containing the SINGLE view of tt_news
# id_singleView = 18
# Call the PHP script
# file = fileadmin/scripts/imagebox_parser.php
# }
}
lib.parseFunc.tags.imagebox < tt_content.text.20.parseFunc.tags.imagebox
should be able to replace content between tags.
I've commented call to php function just tried to get a text replacement for starters.
I've put that in the main root template Setup, but nothing is replaced.
I've also tried other examples from the web with no success.
Did anyone have situation like this?
Are there better approaches for that in TYPO3? (I'm using v7.6.23)
Any suggestion or hint is appreciated.
EDIT: using FSC on textmedia element
I think your examples are outdated. (the object PHP_SCRIPT is obsolete for a long time)
You might have a look at the documentation for your TYPO3 version:
https://docs.typo3.org/typo3cms/TyposcriptReference/7.6/Functions/Parsefunc/
you also need to enhance the parsefunc where you need it. That can depend on:
CSC or FSC?
which kind of content element (CE) do you use? (be sure to enhance the rendering of that CE)
I want to get the html of pdf manager using bean. I know how to get the html for email template but unable to get the html for pdf template which u build in pdf manager.
$template = new EmailTemplate();
$template->retrieve_by_string_fields(array(‘name’ => $template_name,’type’=>’email’));
$html=$template->body_html;
How can i achieve the same functionality when i want to get the html template from pdf manager?
The retrieve_by_string_fields function is deprecated as of 7.6 as per this, so you might want to consider using SugarQuery instead. There's no "type" field in the PDF Manager, so I've just gone with the name attribute from your code. This should provide you with an array of records matching the condition.
require_once("include/SugarQuery/SugarQuery.php");
$sugarQuery = new SugarQuery();
$sugarQuery->select("body_html");
$sugarQuery->from(BeanFactory::newBean('PdfManager'));
$sugarQuery->where()->equals("name", $template_name);
$html = $sugarQuery->execute();
I need the teaser as pure plain text , without any links or text formatting in the Latest view, the possibility . Is it provided for a corresponding ViewHelper or a different approach ?
HTML entities , it should not be served as & for & for example.
Use <f:format.stripTags> Viewhelper.
To ensure all html entities are decoded use <f:format.htmlentitiesDecode>
So you can use:
<f:format.stripTags>
<f:format.htmlentitiesDecode>
{newsTeaserVar}
</f:format.htmlentitiesDecode>
</f:format.stripTags>
The news list is rendered using a partial for each item (Resources/Private/Partials/List/Item.html). In that, you can see the line used for rendering the teaser:
{newsItem.teaser -> f:format.crop(maxCharacters: '{settings.cropMaxCharacters}', respectWordBoundaries:'1') -> f:format.html()}
If you remove the last view helper f:format.html(), then it won’t be converted to HTML. If you replace it with f:format.raw() (in case you have HTML in the teaser), then the HTML will be output as is, w/o converting < to < and > to > etc.
When overriding the partials, you should not directly modify the extension, but do it in an upgrade-safe way. For that, put them in your site extension or into fileadmin/ and add that partials path to the TS config:
plugin.tx_productview {
view {
partialRootPaths.1 = [path to partials folder]
}
}
For news, there is also a special mechanism: you can set a constant
plugin.tx_news.view.partialRootPath = […]
to the path.
I'm trying to allow javascript in rich text editor inputs in my Umbraco setup. I'm using Umbraco 7.2. I've enabled the script tag in tinyMceConfig.config so the editor no longer eats my script tags. The problem now is that my content is cut off.
For example, in my RTE I put:
<p>before</p>
<script>
alert('blam');
</script>
<p>after</p>
This get's transformed by TinyMCE to:
<p>before</p>
<script>// <![CDATA[
alert('blam');
// ]]></script>
<p>after</p>
The problem is the value of Umbraco.Field("myRte") ends up being:
<p>before</p>
<script>// <![CDATA[
alert('blam');
// ]]
It seems related to CDATA. Does anyone else have javascript in RTE working in Umbraco 7?
A possible workaround would be to create a macro that would allow you to insert a script into the RTE. The macro would have a single Textarea parameter where you would paste in your script tag, and you would simply render the parameter value as raw Html. However, it might be a good idea to check that the input is valid html before you attempt to render it on the page.
If you use a razor macro the partial view could look like this:
#inherits Umbraco.Web.Macros.PartialViewMacroPage
#{
var script = Model.MacroParameters["script"].ToString();
}
#if (!script.IsNullOrWhiteSpace())
{
#Html.ValidateHtml(script)
}
Where ValidateHtml is an extension method to the Mvc HtmlHelper:
public static IHtmlString ValidateHtml(this HtmlHelper helper, string input)
{
if (!string.IsNullOrEmpty(input))
{
var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(input);
if (htmlDoc.ParseErrors.Count() == 0)
{
return new MvcHtmlString(input);
}
}
return null;
}
The helper method uses the Html Agility Pack and I got the code from an answer posted to another SO question.
I've tested this on an Umbraco 7.2.1 install and it works fine even if you select the "Render in rich text editor and the grid" option.
My solution is not write direct script in editor, write it in a test.js file after that include
<script src="https:/....test.js></script>
In tiniMceConfig.config file (config folder)
validElements tag, add this
,script[type|src|language]
so it will look like this
<![CDATA[+a[id|style|rel
.....
,bdo,button,script[type|src|language]]]>
Test and work on Umbraco 4.7.x. I'm not test on umbraco 7