Insert new line in mail template override - plone

In email templates like this: https://github.com/plone/Products.PasswordResetTool/blob/master/Products/PasswordResetTool/skins/PasswordReset/mail_password_template.pt
how to add new lines in my customized text?
I'm trying to say:
Hello
Some text
and the result is:
Hello Some text
I think it is related to Content-Type: text/plain.
UPDATE:
Tried:
aaa \n
aaa
bbb \r\n\r\n
bbb
ccc <br>
ccc
ddd <br />
ddd
eee
eeee
The result is a single line:
aaa \n aaa bbb \r\n\r\n bbb ccc <br> ccc ddd <br /> ddd eee eeee

After simplifying the template it works without any special tricks.
<tal:root define="lt string:<;gt string:>;
member python:options['member'];
portal_state context/##plone_portal_state;
view context/##passwordreset_view;
isAnon context/##plone_portal_state/anonymous;
reset python:options['reset']"
>From: <span tal:replace="structure view/encoded_mail_sender" />
To: <span tal:replace="python:member.getProperty('email')" />
Subject: Request to reset your password
Content-Type: text/plain
Precedence: bulk
Hello
Some text
More text
Kind regards
Organization Name
</tal:root>
return the text as I need it:
Hello
Some text
More text
Kind regards
Organization Name

Related

R, XPath, text scraping : get the text inside a node, while filtering on the attribute value of one of its descendant

Here is a quick mock-code. What I want to get is a character vector, with the text content of each p-node for whom the descendant a has its attribute href = "value1".
<doc>
<div class="intervention">
<p>
<a></a>
<b>
xxx
</b>
text1
</p>
<p>
<a></a>
<b>
xxx
</b>
text2
</p>
<p>
<a></a>
<b>
xxx
</b>
text3
</p>
</div>
<div class="intervention">
<p>
<a></a>
<b>
xxx
</b>
text4
</p>
<p>
<a></a>
<b>
xxx
</b>
text5
</p>
<p>
<a></a>
<b>
xxx
</b>
text6
</p>
</div>
</doc>
In other words, I want to get this vector:
c("xxxtext1","xxxtext3","xxxtext5","xxxtext6")
Could you please help me find the adequate XPath? So far, I have found this one that gives me all the text content in the p node, but I cannot get it to filter based on a's href value.
"//div[#class='intervention']//*[not(self::script)]"
Many thanks in advance for your help!
Your xpath should be //a[#href='value1']/ancestor::p
So for example:
library(xml2)
result <- xml_text(xml_find_all(doc, xpath = "//a[#href='value1']/ancestor::p"))
gsub("\\s", "", result) # Remove line breaks and spaces
#> [1] "xxxtext1" "xxxtext3" "xxxtext5" "xxxtext6"

float property does not work

I have a problem with float. The text does not flow the picture from the right side except for the first line. When I create a new html document and insert a picture with description everything works fine. I don't know where the problem is.
Here's the html:
<div id="container">
<div id="logo">
<h1>Best movies of all time!</h1>
</div>
<div id="nav">
Shawshank Redemption <br />
Forrest Gump <br />
Seven <br />
The Lord of the Rings <br />
American Gangster <br />
</div>
<div id="content">
<h2>Shawshank Redemption</h2>
<p id="shawshank_description">
<img id="shwashank" src="img/shawshank.jpg" width="200" height="150" />
The Shawshank Redemption is a 1994 American drama film written and directed by Frank Darabont, and starring Tim Robbins and Morgan Freeman. Adapted from the Stephen King novella Rita Hayworth and Shawshank Redemption, the film tells the story of Andy Dufresne, a banker who is sentenced to life in Shawshank State Penitentiary for the murder of his wife and her lover, despite his claims of innocence. During his time at the prison, he befriends a fellow inmate, Ellis Boyd "Red" Redding, and finds himself protected by the guards after the warden begins using him in his money-laundering operation. Although it was a box office disappointment, the film received multiple award nominations (including seven Oscar nominations) and outstanding reviews from critics for its acting, story, and realism. It has since been successful on cable television, VHS, DVD, and Blu-ray. It was included in the American Film Institute's 100 Years...100 Movies 10th Anniversary Edition.[4] It is considered to be one of the greatest films of all time. The Shawshank Redemption is a 1994 American drama film written and directed by Frank Darabont, and starring Tim Robbins and Morgan Freeman. Adapted from the Stephen King novella Rita Hayworth and Shawshank Redemption, the film tells the story of Andy Dufresne, a banker who is sentenced to life in Shawshank State Penitentiary for the murder of his wife and her lover, despite his claims of innocence.
</p>
</div>
<div id="ad">
<img src="img/banner.gif" />
</div>
<div id="footer">
Best movies of all time! © All rights reserved
</div>
</div>
Here's the css:
#shawshank {
float: left;
}
The issue here is that your float: left styling is not being applied... Try this:
HTML:
<p id="shawshank_description">
<div class="shank_image">
<img src="img/shawshank.jpg" width="200" height="150" />
</div>
It is considered to be one of the greatest films of all time...
</p>
CSS:
.shank_image img{
float: left;
}
https://jsfiddle.net/qbbbm514/
In your CSS file, you need #shawshank {...} instead of just shawshank{...}, since you are targeting an element by its id. Also I noticed in your code the id property on your image is "shwashank" instead of "shawshank", so that could be an issue too.
Also, your floats may not work with your current nesting of the image inside the paragraph tag, since they are supposed to float alongside each other. Try:
<img id="shawshank" src="img/shawshank.jpg" width="200" height="150" />
<p id="shawshank_description">...</p>
And in your CSS file add:
#shawshank_description {
float: right;
}

Remove a <img tag from the table using SQL Server 2012

I am using SQL Server 2012 and my data and image is inserted from a richtextbox from asp.net and I need help to display only text, not image, from the specific field from the table.
Here is an example:-
<p>The Brando is an exquisite luxury resort on French Polynesia’s breathtakingly beautiful private atoll of Tetiaroa,
<img style="width: 100%;" src="../images/InfrastructureImage/The Brando, French Polynesia 2.jpgc05350ab-ba5d-465f-91da-4b9edb8fce47.jpg"
alt="The Brando, French Polynesia 2.jpg" />
</p>
into this example I want only text not image which is on the <img> tag I want to remove the complete image tag. I need help fetching only the text.
Please help me with this
In your dataLayer
Text = Regex.Replace(reader["Htmltext"] as string, "<img.*?>", String.Empty);
Split and get. Not a clean process but its work.
string YourReceiveValue="<p>The Brando is an exquisite luxury resort on French Polynesia’s breathtakingly beautiful private atoll of Tetiaroa,<img style="width: 100%;" src="../images/InfrastructureImage/The Brando, French Polynesia 2.jpgc05350ab-ba5d-465f-91da-4b9edb8fce47.jpg" alt="The Brando, French Polynesia 2.jpg" /></p>"
string[] result = YourReceiveValue.Split(new string[] { "<img" }, StringSplitOptions.None);
string RemoveImage=result[0] + "</p>"; // Get back Closing tag of p

Convert text to paragraph in Liquid Template

I'm trying to convert a raw string to html with the Liquid templating language. What I want to do is convert this:
Hello. This
is a text.
Please convert me.
into this:
<p>Hello. This<br />
is a text.</p>
<p>Please convert me.</p>
What I tried
{{ mytextvariable | newline_to_br | replace: "<br />\n<br />", "</p><p>" | replace: "<p></p>", "" | prepend: '<p>' | append: '</p>' }}
but this gives me (notice double <br />):
<p>Hello. This<br />
is a text.<br />
<br />
Please convert me.</p>
Site note
This will be used for a Shopify site.
You're replacing new lines with break tags when using newline_to_br, so the first replacement won't replace anything, newlines are gone.
From what I can see, Liquid does not support regular expressions, so the replace: "<br />\n<br />" will probably be interpreted literally.
Might be easier to implement as a new filter?
... something like this:
def newline_to_p_or_br(input)
input.to_s.gsub(/(.*?)\n\n/, "<p>\1</p>").gsub(/\n/, "<br />\n")
end
Here is the definition of newline_to_br for reference:
http://rubydoc.info/gems/liquid/2.2.2/Liquid/StandardFilters:newline_to_br

Display Wordpress Category

I want to display only the those parent category name and with their child category..
Example category
AAAAA,BBBB,CCCCC,DDDDD
Parent category AAAAA having child category a,b,c
Parent category BBBB having child category x,y,z
Now I want to display only (Result required)
AAAAA
a,b,c
BBBB
x,y,z
Please help me...
If CCCCC's id is 17 and DDDDD id is 38, then the following example would work.
<ul>
<?php wp_list_pages('exclude=17,38' ); ?>
</ul>

Resources