CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Email Clickable in Profile View on Public Search
Pages: [1]

Author Topic: Email Clickable in Profile View on Public Search  (Read 2221 times)

digitalzen

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Email Clickable in Profile View on Public Search
June 03, 2010, 03:27:04 pm
Hi Guys,

I know Donald answered this before here, but the wiki link provided doesn't work, and I suspect the answer may not apply to exactly what I'm trying to do...

Here's the public search page I'm working on:

http://www.shorelinechamber.com/index.php?option=com_civicrm&task=civicrm/profile&force=1&gid=7

I would like to make it work so that when you view an individual record/profile from the results list (by clicking 'View', the email is linked (similar to how web address is handled), such that it launches the visitor's mail client with the email address populated in 'To:' (ie. similar to mailto:soandso@suchandsuch.com).

Stated much more simply, I'd like to allow site visitors to email individual members directly from the profiles in search results.

Please guide me, so I don't break something important and get myself into trouble.  :P

Thanks!
Chris

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Email Clickable in Profile View on Public Search
June 07, 2010, 11:53:12 am
Chris - If you've never customized a CiviCRM template before, then first step is to review these pages for overview:
http://en.flossmanuals.net/CiviCRM/DevelopTemplates
http://wiki.civicrm.org/confluence/display/CRMDOC/Customize+Built-in%2C+Profile%2C+Contribution+and+Event+Registration+Screens

Replace this (starting line 65 in templates/CRM/Profile/Page/Listings.tpl):
Code: [Select]
     {foreach from=$row item=value}
        <td>{$value}</td>
      {/foreach}

... with this code - adjusting the index (4) higher or lower depending on what column the email address is:

Code: [Select]
     {foreach from=$row item=value name=rowCols}
        <td>{if $smarty.foreach.rowCols.index EQ 4}<a href="mailto:{$value}">{$value}</a>{else}{$value}{/if}</td>
      {/foreach}

If this works for you, would be great if you could add a page on the wiki (under the Customizing Profile section) with a "recipe" for this.
Protect your investment in CiviCRM by  becoming a Member!

digitalzen

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Re: Email Clickable in Profile View on Public Search
June 12, 2010, 08:15:42 pm
Hi Dave,

I got it to work, but it wasn't exactly what I was looking for... probably because I muddied my description. The snippet you gave me works beautifully when I include email as a result column in the search results, but what I was hoping to do was edit the Profile Details page (which loads when you click 'View' from the results table).
And actually, I'd like to accomplish a couple of things on the Profile Details page:

1. Unlink all the searchable items (in this case: Full Name, Business Category, Street Address and ZIP)
2. Link the email address using mailto like you showed me above for the Listing table
3. Modify the website link to include a target=_blank attribute

I'm guessing the Profile Details page is not controlled by Listing.tpl, but I can't figure out which .tpl to modify. View.tpl seems to be involved, but as you know, it's a very short template, and I'm not entirely sure that's where I should be looking, although it had some comments about customization which I sort of understood, but couldn't see how I'd use it to do things like overriding the search links.

I appreciate your patience and guidance, as I sincerely want to learn to use this system effectively, but am a little lacking in the .php knowledge, and don't fully grasp the Smarty syntax. I'm picking it up, but I realize I've got a bit of learning curve to get over here. The documentation you referred me to so far has been very helpful, and I intend to spend more time delving into Smarty, because as I said, I really want to understand this.

I'll still be glad to contribute to the wiki once I have a handle on what I'm doing.

Thanks!
Chris
« Last Edit: June 12, 2010, 08:22:18 pm by digitalzen »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Email Clickable in Profile View on Public Search
June 14, 2010, 11:41:48 am
The fields on the page you want to change are rendered by templates/CRM/Profile/Page/Dynamic.tpl - so you'll need to create a custom version of that .tpl file and do a conditional on the label to see if you need to transform the value. Something like this:

Code: [Select]
     <div class="content">
        {if $rowName EQ "Email Address"}<a href="mailto:{$value}">{$value}</a>{else}{$value}{/if}
     </div>


Follow the directions on the wiki for creating the correct custom path for this so that the .tpl is specific to the Profile, eg. if Profile ID = 2:

/var/www/civicrm_custom/CRM/Profile/Page/2/Dynamic.tpl



Protect your investment in CiviCRM by  becoming a Member!

digitalzen

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Re: Email Clickable in Profile View on Public Search
June 14, 2010, 10:57:16 pm
Awesome! I'll try it in the next day or so and let you know how it goes, then start drafting a "recipe" if I get it to work.

Thanks, Dave!

C

digitalzen

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Re: Email Clickable in Profile View on Public Search
June 15, 2010, 10:59:13 pm
FAN-TASTIC!!! After a little bit of mucking around, I set up my civicrm_custom folder path (I keep trying to make everything harder than it really is! :P) and got the email piece to work, which is HUUUUUUGE! Thanks!!!  :D

Next step: On the same page, how do I suppress the linking that CiviCRM does on other fields to make them NOT clickable? I tried using inline CSS with a div wrapped around {$value} in the {else} statement to at least hide it, like this:

Code: [Select]
{else}
   <div style="text-decoration: none; color: black;">{$value}</div>
{/if}

... but that didn't work. I presume this is because whatever's coming in as part of {$value} beats out my inline style in order of CSS priority.

I suspect this will also feed my last question, which is how to add target="_blank" to the 'Website' value. I tried the following code:

Code: [Select]
{if $rowName EQ "Email (Primary)"}
   <a href="mailto:{$value}">{$value}</a>
{elseif $rowName EQ "Website"}
   <a href="{$value}" target="_blank">($value}</a>
{else}
   {$value}
{/if}

... but it rendered as a sort of mangled link within a link bit of html. Again, because there's already an <a href=url>url</a> coming in with {$value}. I know I'm close, but I just can't figure out how to get around the automatic linking of specific values on that page. Is this possible?

Also, a basic programming question not covered in the Smarty documentation: are multiple {elseif} statements permitted within an {if}{/if} wrapper, or do I need to set up an array? This may be a moot question, depending on how I would go about suppressing the linking on values.

As always, thanks for your help. I think I'm finally starting to get some of this through my thick skull. ;)

Chris
« Last Edit: June 16, 2010, 10:03:12 am by digitalzen »

digitalzen

  • I post occasionally
  • **
  • Posts: 46
  • Karma: 0
Re: Email Clickable in Profile View on Public Search
June 16, 2010, 10:39:47 am
Hey, I figured it out! I just needed to change those fields to 'Public Pages' rather than 'Public Pages and Listings'. RTFM :)

I think maybe I've got it all sorted out at this point. The only lingering question is how to get a 'target=_blank' attribute onto the website link, but that's not mission-critical, although it would be very cool to have (don't want people navigating away from the site and forgetting to come back).

Thanks again for your help, Dave! Is it okay if I send my draft "recipe" to you directly for inclusion in the Wiki? I'm not very good with Wiki editing, and would be nervous about adding anything to your documentation without having it reviewed first.

Chris
« Last Edit: June 16, 2010, 10:44:04 am by digitalzen »

Franck-AWO

  • I’m new here
  • *
  • Posts: 7
  • Karma: 1
    • l'AtelierWeb.Org
  • CiviCRM version: 4.3.7
  • CMS version: Drupal 7.23
  • MySQL version: 5.1.66
  • PHP version: 5.3.5
Re: Email Clickable in Profile View on Public Search
May 24, 2013, 02:59:29 am
Quote from: Dave Greenberg on June 14, 2010, 11:41:48 am
The fields on the page you want to change are rendered by templates/CRM/Profile/Page/Dynamic.tpl - so you'll need to create a custom version of that .tpl file and do a conditional on the label to see if you need to transform the value. Something like this:

Code: [Select]
     <div class="content">
        {if $rowName EQ "Email Address"}<a href="mailto:{$value}">{$value}</a>{else}{$value}{/if}
     </div>

Follow the directions on the wiki for creating the correct custom path for this so that the .tpl is specific to the Profile, eg. if Profile ID = 2:

/var/www/civicrm_custom/CRM/Profile/Page/2/Dynamic.tpl

I would like to cloak the email addresses showed in public accessible profiles, I mean make the email addresses less accessible/readable for spambot (with Joomla 2.5.9 and CiviCRM 4.2.9).
There is email cloaker plugin in Joomla! core but it seems not working within CiviCRM views. There are other Joomla! plugins that could do it but I would prefer an internal CiviCRM or Joomla! function.

So here is what I use  :

Code: [Select]
                 <div class="content" style="font-weight: bold;">
                    {if $rowName EQ "email_Primary"}{mailto address=$field.value encode='javascript' subject='Bonjour'}{else}{$field.value}{/if}
                 </div>

Thanks to http://www.smarty.net/docsv2/fr/tips.obfuscating.email.tpl too ;)
I did not succeded to make encode='hex' work.

I did not found on the web a 100% spambot proof solution that let email adresse readable/clickable by humans - or may be some like using a GIF but we can not use <a href="mailto... So if someone knows a better and easy solution that the one provide by the smarty mailto function, I would be glad to try it.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Email Clickable in Profile View on Public Search

This forum was archived on 2017-11-26.