Internal link in email? - email

How do I insert an internal link in an email?
Here's html I open in browser, copy-paste in gmail, send it to myself and expect its internal links to be working:
<html>
<body>
<p>Birds</p>
<p>Trees</p>
<p>Flowers</p>
<h4 id="Title1">Birds</h4>
<p> There are many different birds. There are... </p>
<h4 id="Title2">Trees</h4>
<p> Trees have many different colors and branches... </p>
<h4 id="Title3">Flowers</h4>
<p> The Lignum Vitae is the national flower of Jamaica... </p>
</body>
</html>
Edit:
I'm sending the following to my self:
<html>
<body>
<p>Birds</p>
<p>Trees</p>
<p>Flowers</p>
<h4 id="Title1"><a name="Title1">Birds</a></h4>
<p> There are many different birds. There are... HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs. HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs.</p>
<h4 id="Title2"><a name="Title2">Trees</a></h4>
<p> Trees have many different colors and branches... HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs. HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs.</p>
<h4 id="Title3"><a name="Title3">Flowers</a></h4>
<p> The Lignum Vitae is the national flower of Jamaica... HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs. HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs.</p>
</body>
</html>
and links aren't clickable. What do I do wrong?

In gmail you will need to use named anchors:
<a name="Title1">Birds</a>
As you might expect, different email clients... work differently. Some support internal links to IDs; some don't; some support both. AFAIK gmail only supports named anchors. Bear in mind that there will likely be some email clients that won't support internal linking at all.
The id in the h4 isn't strictly necessary since the named anchor should work in the majority of email clients. However, there is no reason not to have both as far as I can tell. The following works for me in Gmail:
<h4 id="Title1"><a name="Title1">Birds</a></h4>
HOWEVER, it should be noted that Gmail appears to override the default browser/HTML functionality with JavaScript (and inserts a prefix into the named anchor and corresponding href so as not to interfere with its web interface). Consequently it seems that Gmail will only scroll to the named anchor if it is currently out of view - if it is already visible then no scroll occurs.

Related

Automated material UI components using watir or selenium

I am trying to find out if anyone has an approach to automated UI testing on Material UI components.
Material UI elements are rendered as nested divs with very little unique id information, for example:
<div data-reactroot style="...">
<div style="...">
<div style="...">
</div>
</div>
</div>
The nested div structure makes using traditional location methods difficult if not impossible - (Selenium and Watir), id, name, class, etc.
Using react devtools, one can see a much clearer picture of how the page is structured, but I am not yet able to access the React "DOM" to locate elements.
Any ideas or help would be appreciated.
Added example:
Sliders
I can't come up with an example that is more descriptive than the one above, could literally be 10 layers of nested divs without any text.
There is no general method I'm aware of, unfortunately.
Some of the components already have ids, which allows you to use a css selector like #my-component input (which is usually enough to get an exact field), others have custom class names to be added (like AutoComplete - popoverProps) which allows you to use a similar selector.
Good news is that every MaterialUI component provides className, which can be used to locate elements (at least partially) - details can be found at http://www.material-ui.com/#/customization/styles
Also id field works quite often, even when not documented.
At the last resort (if detection by class + other css selector parts is not sufficient) you can fall back to XPath expression using element text - for example, I use //span[#class="menu-item"][.//div[contains(text(),"${itemName}")]] for matching menu items. It matches things declared as <MenuItem primaryText={itemName} className="menu-item">

RichText in Magnolia CMS is changing HTML text

I would like to ask how I can block richText from changing html text under source view.
I'm using Blossom module and defined richText as #Chris J advised me to do:
Add source button to Magnolia CMS richText control
Whenever I put html code in source code, switch to normal view and get back to source view the code is changed. For example the following part of code is missing :
<div class="components"> <div class="product col img-slider"> <div id="product-image" class="royalSlider productImage rsDefault"> <div class="rsContent"> <div class="rsTmb"><img src="/magnoliaPublic/resources/XXX/products/product_7.jpg" alt="">
and is replaced with folowing
<p><img alt="" src="/magnoliaPublic/resources/XXX/products/product_7.jpg" /></p>
I need to provide the possibility for the user to put html code and next to see in on the web page.
Regards
Jan
Jan. I'd ask why you are using a rich text area if you are entering HTML. It is not really designed for this usage. Would you be better off with an ordinary text field? In the STK (you mentioned this in your previous question) you will find a component that serves exactly this purpose.
Under "Configuration" you will find it at /modules/standard-templating-kit/templates/components/content/stkHTML
You will see that the template script is simply:
[#if content.editHTML?has_content]
${cmsfn.decode(content).editHTML}
[/#if]
If you want to stick with a purely Blossom approach, you may need to recreate this but it is an incredibly simple component.
Incidentally, in Magnolia 5.4 there is a code editing field used in a similar component that offers syntax highlighting. You can see this by logging into the demo site and trying to add an HTML component to the main area of the page travel/contact.

Assign Class to CKEditor using a DIV

I am using CKEditor in DIV mode, as compared to an IFRAME and I am attempting to assign a class to the editor itself. I have found where to add it to things within the editor, but not the editor itself. And, I would prefer to not wrap the editor within another DIV to get the effect I want.
I am also using version 4 of CKEditor.
Edit: The following was my questions to Reinmar after he suggested the Shared Space plugin, which at least for now I have chosen not to use.
Edit: In response to Reinmar I have begun using the Shared Space plugin, and do see the potential benefits of using it over a DIV.
With that said I have the following code:
<div id="topSpace"></div>
<textarea name="data[ArchiveQuarter][description]" class="userContent" id="editor1" cols="30" rows="6"></textarea>
At the bottom of the page I have:
<script type="text/javascript">
CKEDITOR.disableAutoInline = true;
CKEDITOR.replace( 'editor1', {
extraPlugins: 'sharedspace',
sharedSpaces: {
top: 'topSpace',
}
});
</script>
It currently creates the toolbar within the top space, and has the textarea, but both of them are disabled. I probably just messed up some of the configuration, but I'm not sure what.
I would greatly prefer it to use the textarea configuration as it is part of a form instead of extracting the data from inline.
You might be interested in using Shared space plugin:
addon page,
sample.
I'm proposing this instead of using div, because I've got mixed feelings regarding divarea plugin. Your original container is wrapped with editor's structure what changes the real context. IMO it's better to use real inline editing + the shared spaces feature to place toolbar and bottom bar where you need them.
Update:
When you're using inline editor, you don't need textarea. Textarea is only a data container which framed or div based editors replace with themselves.
Inline editing is all about editing real existing elements. So this can be your HTML:
<div id="topSpace"></div>
<div class="userContent" id="editor1"><h1>My page</h1><p>Fooo!</p></div>
And JS:
<script type="text/javascript">
CKEDITOR.disableAutoInline = true;
CKEDITOR.inline( 'editor1', {
extraPlugins: 'sharedspace',
sharedSpaces: {
top: 'topSpace',
}
} );
</script>
Note that I used CKEDITOR.inline not CKEDITOR.replace.
And the huge advantage of inline editing is that that <div> is a real element on your page - it is not wrapped (as in div based editor) and its contents is not moved to the frame (as in framed editor). So your content will inherit styles of your page.
The downside is that you need to implement custom data saving, because there's no form. The simplest way is to add a "save" button which clicked will send editor.getData() via AJAX to your server.
BTW. You probably was confused by the fact that in the shared spaces sample 2 editors are framed and 2 are inline. All of them reuses one top space and one bottom space.
BTW2. To make use of inline editing you don't need shared spaces in fact. Then the "floating toolbar" will be used as in here: http://ckeditor.com/demo#inline

How to handle html templates in MVC2?

My (MVC2) application displays several addresses in a View.
Each address contains just a subset of information, like first- and lastname. The request is that the complete address information should be displayed when the mouse is over a result.
An html template should be used therefor.
This template defines how(!) the complete address should be displayed – but it doesn’t defines what(!) should be displayed.
Means it can be assumed that the complete address is always “firstname“, “lastname”, “street”, “zipcode” and “city” (for example and to keep it simple). This will never be changed.
But for example the background color can be changed in the html template from white to green or the size of the lastname can be changed from <h1> to <h2> …
What is the best way to solve it?
I would prefer to write some shared code (keyword: ascx).
This shared code should wrap the template, would be very easy and would look like this:
<div id=”mouseOver” style="display: none;" >
X_REPLACE_X
</div>
The template would look like this simplified example:
FirstName: {Name}<br/>
Lastname: <h1>{Lastname}/<h1><br/>
ZipCode: {ZipCode}<br/>
I would then render the ascx code via “Html.RenderPartial” on the View and map each address to a javascript mouseover function.
The javascript function would replace the placeholder (like {FistName}, {LastName} , etc.) in the template, position and display it.
And thats my problem:
The template should NOT be put directly in the wrapper (ascx - code)!
Means at runtime must “X_REPLACE_X” be replaced with a somewhere on the server stored template.
Because this gives me the ability to change the template without changing and publishing the code!
How can this be managed?
Is there a much better way to solve it? Should I use instead ajax calls to get the template in a variable?
Any help would be really great!
thxs in advance!
It sounds like the best way to accommodate your display differences is to simply use different css classes. The html template used for the full information does not change and can be used for all addresses, while the differences between background colors and text size can be handled by different css settings.
Relatedly, I wouldn't handle the different text sizes by using <h1></h1> and <h2></h2> but rather a common tag (such as <span></span>) whose text size is handled via css.

Render differences between html.RenderPartial and <%# register

Ok, I have a master page which I include an ascx...
<%# register tagname="header" tagprefix="vb" src="~/Views/Controls/Header/Header.ascx" %>
<vb:header id="pageHeader" runat="server" />
The ascx has a site map which uses the MvcSiteMapProvider...
<asp:SiteMapDataSource id="SiteMapDataSource1" sitemapprovider="Secure" showstartingnode="false" runat="server" />
<asp:menu id="headerMenu" DataSourceID="siteMap" orientation="Horizontal" staticenabledefaultpopoutimage="false" runat="server" IncludeStyleBlock="false"></asp:menu>
Everything works nicely and then I needed to pass the model into the control so changed the master page to
html.RenderPartial("~/Views/Controls/Header/Header.ascx", Model)
Now I get a runtime error "Control '2_headerMenu' of type 'Menu' must be placed inside a form tag with runat=server." and Yes I do have a Form tag with runat=server in the master page.
Therefore does anyone know the render differences between these two approaches or any other pointers??
Thanks in advance.
Didn't think MVC will automatically find the ascx in that directory will it?
Yes pretty sure the Control is set up properly and loads OK until it tries to render the asp:menu
Try to not use the relative path but just the name of the partial view
html.RenderPartial("Header", Model);
Now, another important point is to specify what kind of object you are using in your partial view. The first line should be:
<%# Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<OBJECT-TYPE>" %>
Replace OBJECT-TYPE by the object type.
The problem as one commentor noted is that you are mixing a WebForm control in an MVC view. As the error you are receiving states, the Menu has to be within the child control hierarchy of a <form runat="server"/> control. The MVC helpers such as Html.RenderPartial do not do anything with the control tree. Ideally you should not mix MVC and WebForms controls. It can work in certain situations but fails in others.
I have the same trouble! just posted a question like that! In my opinion the partial rendered page is not aware of the parent page and that's why you get an int instead of the address of the parent page!
In case you want to generate a Static ClientID you can use this feature in .NET 4! It will be easier to code your JavaScript code knowing that the value won't change!