I'm sure this is easy but I cant get the email to display the way i want it.
I have inserted the email page field added my "insert before field" text but how do I make it a mailto hyperlink with the email item in the mailto part?
Sorry for the slow reply guys, appreciate all your responses...going for the Razor option, just need to hide the "Email:" if there is no email entered.
It's my understanding that any email in plain text can be read by a spambot. Some spam bots can do patten recognition on email addresses rendered as images but these tend to be more expensive to construct / opperate and are therefore much rarer.
If you are worried about the emails being sniffed, I would consider using ImageGen to render them out as images.
Insert page field - Email
I'm sure this is easy but I cant get the email to display the way i want it.
I have inserted the email page field added my "insert before field" text but how do I make it a mailto hyperlink with the email item in the mailto part?
S
Hi Stephen
Could you perhaps post the code you're trying to get working? Think that will make it more easy to suggest solutions :)
/Jan
Thanks Jan...here is the code.
<umbraco:Item field="locationEmail" insertTextBefore="<b>Email: </b>" runat="server"></umbraco:Item>
Will this need to become a marco to allow me to make this an email link...
S
Hi Stephen,
Can use some quick and dirty inline XSLT,
<b>Email: </b> <umbraco:item Field="locationEmail" runat="server" recursive="true" Xslt="concat('<a href="mailto:', {0} , '">', {0} , '</a>')" XsltDisableEscaping="true" />
Or use an inline razor macro,
Tom
Here's the Razor version;
<umbraco:macro language="razor" runat="server">
<b>Email: </b><a href="mailto:@Model.locationEmail">@Model.locationEmail</a>
</umbraco:macro>
Sorry for the slow reply guys, appreciate all your responses...going for the Razor option, just need to hide the "Email:" if there is no email entered.
Many thanks,
S
Hi Stephen,
You can use razor's HasValue() check;
<umbraco:macro language="razor" runat="server">
@{
if (Model.HasValue("locationEmail"))
{
<b>Email: </b><a href="mailto:@Model.locationEmail">@Model.locationEmail</a>
}
}
</umbraco:macro>
I find this cheat sheet really helpful as a quick razor reference; http://our.umbraco.org/projects/developer-tools/razor-dynamicnode-cheat-sheet
Many Thanks,
Tom
wierd I'm getting a "Error loading Razor Script DisplayEmail.cshtml" on that script...do i need the
if (Model.HasValue("locationEmail")) to be
if (@Model.HasValue("locationEmail"))?
S
Hi Stephen,
Are you using the code in an external razor script file?
The code I posted can be used inline on a master page - so you don't need to create an umbraco macro, or macro script file to run it,
Many Thanks,
Tom
Sorry to hijack this post, but I have a related question as I have a similar solution, where I insert our staff email addresses on a site via a macro.
My question is if the email is spambot searchable?
@using umbraco.MacroEngines
@{
var nodeId = PageData[0];
var staff = Library.NodeById(nodeId);
}
<div class="staff">
<div class="name">@staff.Name</div>
<div class="jobtitle">@staff.title</div>
<div class="phone">Tlf: @staff.telephone</div>
<div class="email">Email: <a href="mailto:@staff.email">@staff.email</a></div>
</div>
Mark.
Hi Mark,
It's my understanding that any email in plain text can be read by a spambot. Some spam bots can do patten recognition on email addresses rendered as images but these tend to be more expensive to construct / opperate and are therefore much rarer.
If you are worried about the emails being sniffed, I would consider using ImageGen to render them out as images.
Something like:
<img src="/[email protected]&Font=Arial&FontColor=f1f7f0&FontSize=600&FontStyle=bold" />
The image gen module could be in the umbraco folder in you implementation. Also, refer to the image gen docs here for more info on fonts etc http://www.percipientstudios.com/imagegen/documentation.aspx
Many Thanks,
Tom
is working on a reply...