Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
hello!

I'm using an image for a mailto link and I wonder if it's possible to harness the Couch cms:cloak-email tag with the following:
Code: Select all
<a href="mailto:<cms:get_custom_field 'email_address' masterpage='globals.php' />" /><img src="<cms:show k_site_link />img/email.png"/></a>


I don't think so, but someone else might know better - thanks!
Hi potato,

That's a tricky one.
We can certainly make the email parameter dynamic so, for example, the following statement
Code: Select all
<cms:cloak_email 'johndoe@gmail.com' />

could be coded as
Code: Select all
<cms:cloak_email "<cms:get_custom_field 'email_address' masterpage='globals.php' />"  />

However, cms:cloak_email tag always outputs an entire chunk of HTML (injected into the DOM through JavaScript) -
Code: Select all
<span id="vcvo1IC5oUsMQg7F">
    <a href="mailto:johndoe@gmail.com">johndoe@gmail.com</a>
</span>

What we could do, I think, is to use JS ourselves and pick up the 'href' attribute from the chunk above and set it into the one you have (i.e. the one with image).

For example
Code: Select all
<div id="hidden-cloaked-email" style="display: none;">
    <cms:cloak_email "<cms:get_custom_field 'email_address' masterpage='globals.php' />"  />
</div>

<a id="your-target-link" href="#" />
    <img src="<cms:show k_site_link />img/email.png"/>
</a>

<script>
    ...
    pick-up the 'href' from 'div#hidden-cloaked-email a'
    and set it into 'a#your-target-link'
    ...
</script>

What do you think about it? Will it work?
thanks for the suggestion KK - am ashamed to say my JS isn't quite up to manipulating fields. This is maybe something I'll come back to on this particular website as I've been tinkering far too long on something so small and must get on :)
3 posts Page 1 of 1