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 »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • linking to drupal profiles from search results pages
Pages: [1]

Author Topic: linking to drupal profiles from search results pages  (Read 2080 times)

tobiaseigen

  • I post frequently
  • ***
  • Posts: 151
  • Karma: 5
    • Kabissa - Space for Change in Africa
linking to drupal profiles from search results pages
February 18, 2008, 07:41:49 pm
Hi,

I am using civicrm 1.9 with a custom Kabissa module providing (among other things) a directory of organizations and the people that work for those organizations. I have seen various references to drupal profile pages in the profile settings, so I know this must be possible: I would like to customize the templates for the search results pages so that they link to the drupal profile pages for people related to organizations in the search results listings, rather than to civicrm pages and contact form. Here is an example:

http://www.kabissa.org/civicrm/profile?reset=1&force=1&gid=3&crmSID=4_d

On that page, the "People" link now links to a listing of people related to the organization. From there you can link to a detailed view and contact form within civicrm. The drupal profile page is more important for us so we'd like to link there for the detailed view, and we would then not need the link to the civicrm contact form.

If anyone has any insights into the code needed to activate the connection between these civicrm pages and drupal profiles, I would be massively grateful.

Cheers,

Tobias
Kabissa - Space for Change in Africa http://kabissa.org

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: linking to drupal profiles from search results pages
February 18, 2008, 09:06:42 pm

your easiest bet is to modify the page listings template to use the links u need displayed. check:


http://wiki.civicrm.org/confluence/display/CRMDOC/Customize+Built-in+and+Profile+Screens

for more details. you also have examples of profiles we've customized (in minor ways) for kabissa

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

veelineen

  • Guest
Re: linking to drupal profiles from search results pages
May 19, 2008, 07:05:41 am
I'm trying to do the same: remove the link for viewing the CIVICRM -profile, leave the link for the drupal profile. I just can't find any of these two links within the templates. It's probably hidden in one of the many templates. Anyone knows where to look for the link?

Thanks a lot!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: linking to drupal profiles from search results pages
May 19, 2008, 12:59:07 pm
The file you'll need to create a custom copy of is templates/CRM/Profile/Page/Listings.tpl

The customization is a bit tricky since all the "action links" (which means both the CiviCRM Profile "View" link and the Drupal user account link) are passed to the template in a single "value". However, I think you should be able to do some string manipulation w/ Smarty to remove the CiviCRM profile link by adding conditional code in that template within this foreach loop (the "cell" you want to modify will always be the last one in each $row array):

Code: [Select]
      {foreach from=$rows item=row}
      <tr id='rowid_{$row.contact_id}' class="{cycle values="odd-row,even-row"}">
      {foreach from=$row item=value}
        <td>{$value}</td>
      {/foreach}
Protect your investment in CiviCRM by  becoming a Member!

veelineen

  • Guest
Re: linking to drupal profiles from search results pages
May 21, 2008, 02:03:53 am
Getting there, but not yet.
I'm able to replace last row with something else. For people who are looking for the same thing, this is the code:

Replace:
Code: [Select]
{counter start=0 skip=1 print=false}
      {foreach from=$rows item=row}
      <tr id='rowid_{$row.contact_id}' class="{cycle values="odd-row,even-row"}">
      {foreach from=$row item=value}
        <td>{$value}</td>
      {/foreach}
      </tr>
      {/foreach}
    </table>

With:
Code: [Select]
      {counter start=0 skip=1 print=false}
      {foreach from=$rows item=row}
      <tr id='rowid_{$row.contact_id}' class="{cycle values="odd-row,even-row"}">
      {foreach from=$row item=value name=your_name}
        <td>{if $smarty.foreach.your_name.last}Display something else{else}{$value}{/if}</td>
      {/foreach}
      </tr>
      {/foreach}
    </table>

Now the content of your last row is replaced with 'Display something else'.

To do next is to enter some custom information into this last row.
There's a $row.contact_id defined for the row-id. But that one isn't working and can't be used.
Therefor I thought to make my own outputfilter within Smarty. I can use the e-mailadress from a user to find the drupal contact_id. So I want to parse the $row[2] in this case (which row number to use can be found using the debugfunction within civicrm and adding &smartyDebug=1 to your URL) to a PHP function that will connect to the db to find the drupal userID and outputs a link to the /user/userID page.

That's where I'm getting lost.
I wrote a function, called smarty_outputfilter_drupal_url
I saved the file as outputfilter.drupal_url.php
Copied the file to: /sites/all/modules/civicrm/packages/Smarty/plugins
But how to connect with the outputfilter from within the template file?
{$row[2]|outputfiler_drupal_url}
isn't working. It seems like the outputfilter isn't registered.

Anyone knows how to handle this problem? I'm nearly there I think.

Thanks again!

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: linking to drupal profiles from search results pages
May 21, 2008, 11:07:57 am
Did you try configuring the profile to INCLUDE the desire Drupal my account link (it outputs w/ "View Website Profile" as the link text i think) - and then use smarty  to remove the other link you don't want ("View Contact" link to CiviCRM profile/view)? The "View Website Profile" link already has the drupal user id in it.
Protect your investment in CiviCRM by  becoming a Member!

veelineen

  • Guest
Re: linking to drupal profiles from search results pages
May 22, 2008, 12:13:28 am
That's what I did at last.
At first I wanted to create the drupal link by myself, since it wasn't a link at itself, but just some text with two link within.

This is working now:
{$value|replace:'Show</a>&nbsp;|&nbsp;':'</a>'}

it gives you an output of:
<a href="civicrmlink"</a><a href="drupallink">Website profile</a>

I will figure out the more decent solution this weekend.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • linking to drupal profiles from search results pages

This forum was archived on 2017-11-26.