Results 1 to 4 of 4

Thread: How to mailto: using a image in a (efg) form listing? Solved

  1. #1
    New user
    Join Date
    07-11-09.
    Location
    Cambridge, UK
    Posts
    11

    Default How to mailto: using a image in a (efg) form listing? Solved

    I have a (members only) efg form listing with a email address as one of the fields. I would like to use an image link to trigger the email.

    If is use the form field contents I get the encrypted :f....&#105 string returned (as expected) However, no matter what I try in the associated listing template (e.g. trying to strip chatacters; calling a file using {{file::xyz.php}} etc to process the email address and return the relvant code) I can not get the correct image link code.

    The Hyperlink content element does allow "mailto:me@somewhere.com" to be linked/triggered via an image (therefore must circumvent the automatic encryption routines). I have tried to create a generic Hyperlink element and reference that in each row of my custom form listing template using {{insert_content::395}}; this woks fine for an email address typed in the Hyperlink element. However I can not get this to work as I want as I cannot seem to reference/pass my efg form email field name (am using $fields[mkmail][content]in the form listing tpl) using an inserttag in the Hyperlink element e.g. "mailto:{{form::mkmail}}", "mailto:{{fd_mkIn::mkmail}}" (mkIn is name of form) do not work (incorrect syntax?) - or even know wether this is possible.

    Would be grateful for any help with a solution - either the Hyperlink element approach, disable the encryption in this instance (as it is on the 'private' side of the site), use of hooks or anything else !. Thnaks.

  2. #2
    New user
    Join Date
    07-11-09.
    Location
    Cambridge, UK
    Posts
    11

    Default Re: How to mailto: using a image in a (efg) form listing? Solved

    I came up with a solution - not pretty/ideal as it involves adding a case statement to the core (Controller.php) but it seems to work (there is probably a better way of doing it). Can explain to anyone who is interested/has the same issue...

  3. #3
    Experienced user
    Join Date
    06-10-09.
    Location
    Atlanta, Georgia
    Posts
    611

    Default Re: How to mailto: using a image in a (efg) form listing? Solved

    Bill - glad you got it figured out. Please do provide an explanation so it can help others with the issue in the future.

    Thanks

  4. #4
    New user
    Join Date
    07-11-09.
    Location
    Cambridge, UK
    Posts
    11

    Default Re: How to mailto: using a image in a (efg) form listing? Solved

    A (non-ideal) solution as follows:
    In the "replaceInsertTags" function in Controll.php I added the following case statement after the 'email' one

    Code:
    case 'emailxx':
      if (strlen($elements[1]))
         {
            $this->import('String');
            $strEmail = $this->String->encodeEmail($elements[1]);
            $arrCache[$strTag] = substr($strEmail,0,strcspn($strEmail,">")-1);
          }
       break;
    This allows me to use the following in my tailored list_fd_xxx.tpl template:

    Code:
    {{emailxx::<?php echo $fields['mkmail']['content'];?>}}?Subject=blablabla  "><img src=..../></a>
    This 'case emailxx' is a direct copy of the 'case email' code except with the sixth line altered. $fields['mkmail']['content'] is my efg form field that contains an email address; this will always give (in TL2.8, where the 'mailto:' is now also encoded):

    encoded-email-address

    no matter how it is treated (as the email address is recognised and processed as part of the page rendering - I assume).
    The {{emailxx ::...}} inserttag will now only return (by stripping out everything from the first '>' and the preceeding ' " ' to the end in the string):

    <a href="encoded-mailto:encoded-email-address

    This allows the addition of further email info (e.g. subject information using other form fields), and also the assignment of an image. This is definitely a kludge, but it seems to be the only way (at present) that I can get an image associated with the mailto: link and still have the address encoded. Any other (better) solutions?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •