Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Stephen 204 posts 246 karma points
    Nov 30, 2011 @ 13:15
    Stephen
    0

    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

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Nov 30, 2011 @ 18:32
    Jan Skovgaard
    1

    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

  • Stephen 204 posts 246 karma points
    Nov 30, 2011 @ 18:38
    Stephen
    0

    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

  • Tom Smith 98 posts 172 karma points
    Nov 30, 2011 @ 18:43
    Tom Smith
    0

    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=&quot;mailto:', {0} , '&quot;>', {0} , '</a>')" XsltDisableEscaping="true" />

    Or use an inline razor macro,

    Tom

     

  • Tom Smith 98 posts 172 karma points
    Nov 30, 2011 @ 18:48
    Tom Smith
    0

    Here's the Razor version;

    <umbraco:macro language="razor" runat="server">

    <b>Email: </b><a href="mailto:@Model.locationEmail">@Model.locationEmail</a>

    </umbraco:macro>

     

    If you need it to look for the email recursively use @Model._locationEmail,
    The xslt example above looks recusively by the recusive="true" property.
    Razor is only available in Umbraco 4.6 upwards,
    Tom
  • Stephen 204 posts 246 karma points
    Dec 01, 2011 @ 17:14
    Stephen
    0

    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

  • Tom Smith 98 posts 172 karma points
    Dec 01, 2011 @ 17:23
    Tom Smith
    1

    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

     

     

     

  • Stephen 204 posts 246 karma points
    Dec 01, 2011 @ 17:37
    Stephen
    0

    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

  • Tom Smith 98 posts 172 karma points
    Dec 02, 2011 @ 00:12
    Tom Smith
    0

    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

  • Mark Thomas 34 posts 127 karma points
    Oct 05, 2012 @ 11:44
    Mark Thomas
    0

    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.

     

  • Tom Smith 98 posts 172 karma points
    Oct 05, 2012 @ 17:57
    Tom Smith
    0

    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

     

Please Sign in or register to post replies

Write your reply to:

Draft