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 Profiles (Moderator: Dave Greenberg) »
  • How do I Remove Sort Name from Profile Search Results?
Pages: [1]

Author Topic: How do I Remove Sort Name from Profile Search Results?  (Read 1956 times)

farmrchrys

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 2
    • Spokane Moves to Amend the Constitution (under development)
  • CiviCRM version: CiviCRM 4.4.6
  • CMS version: Drupal 7.31
  • MySQL version: MySQL 5.5.37
  • PHP version: PHP 5.3.28
How do I Remove Sort Name from Profile Search Results?
May 23, 2009, 06:54:23 am
I have a profile and while setting it up I'm allowed to choose which fields show up in the search results but it seems by default the Sort Name (last name, first name) appears in the search results but I do not want it there. Is there a way to remove that? I'd like to know what I might change in a custom listings.tpl file for this profile to accomplish this.

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: How do I Remove Sort Name from Profile Search Results?
May 23, 2009, 07:55:34 am

I think sort_name is the first (or second) element in the row and columnHeader array. You'll have to suppress it based on what index it appears at. You can use conditionals in smarty to accomplish this. CHeck: http://www.smarty.net/manual/en/ for exact syntax

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

farmrchrys

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 2
    • Spokane Moves to Amend the Constitution (under development)
  • CiviCRM version: CiviCRM 4.4.6
  • CMS version: Drupal 7.31
  • MySQL version: MySQL 5.5.37
  • PHP version: PHP 5.3.28
Re: How do I Remove Sort Name from Profile Search Results?
May 23, 2009, 05:15:16 pm
Donald, Thanks. I think I'm almost there. I didn't think I'd have to learn Smarty along with everything else, but I guess it's good to know.

So, I was able to get rid of the Individual/Organization icon (which I also didn't want here) and the "Name" heading on the listings page, but I can't figure out how to suppress the sort_name value. Here's how I accomplished things so far:

I changed

 
Code: [Select]
<table>
      <tr class="columnheader">
      {foreach from=$columnHeaders item=header}
        <th scope="col">
        {if $header.sort}
          {assign var='key' value=$header.sort}
          {$sort->_response.$key.link}
        {else}
          {$header.name}
        {/if}
         </th>
      {/foreach}
      </tr>
   
      {counter start=0 skip=1 print=false}
      {foreach from=$rows item=row name=listings}
      <tr id="row-{$smarty.foreach.listings.iteration}" class="{cycle values="odd-row,even-row"}">
      {foreach from=$row item=value}
        <td>{$value}</td>
      {/foreach}
      </tr>
      {/foreach}
    </table>


to

Code: [Select]
<table>
      <tr class="columnheader">
      {foreach from=$columnHeaders item=header name=headers}
{if $smarty.foreach.headers.first}
        {* do nothing, and don't show the icon*}
        {else}
 {if ($header.sort eq 'sort_name')}
{else}     
        <th scope="col">
        {if $header.sort}
          {assign var='key' value=$header.sort}
          {$sort->_response.$key.link}
        {else}
          {$header.name}
        {/if}
         </th>
{/if}
{/if}
      {/foreach}
      </tr>
   
      {counter start=0 skip=1 print=false}
      {foreach from=$rows item=row name=listings}
      <tr id="row-{$smarty.foreach.listings.iteration}" class="{cycle values="odd-row,even-row"}">
      {foreach from=$row item=value name=result}
{if $smarty.foreach.result.first}
        {* do nothing, and don't show the icon*}
        {else}
{if ($row.item eq sort_name)}
{else}
        <td>{$value}</td>
{/if}       
{/if}
      {/foreach}
      </tr>
      {/foreach}
    </table>

Now, that last part doesn't work

Code: [Select]
{if ($row.item eq sort_name)}
{else}
        <td>{$value}</td>

It does work if I do this (using my own name):

Code: [Select]
{if ($value eq 'Ostrander, Chrys')}
{else}
        <td>{$value}</td>

So I'm unsure what would be the correct variables to use here. Since this isn't necessarily a Smarty issue, I hope you can give me a suggestion or two. Figuring out where the array is that Smarty is referencing is a bit beyond me.

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: How do I Remove Sort Name from Profile Search Results?
May 23, 2009, 07:39:37 pm
i think you can assume that the image is at zero index and sort_name is at index 1. Given this assumption, the following code will work:

Code: [Select]
      {foreach from=$row item=value name=listingRow}
{if $smarty.foreach.listingRow.index neq 0 AND $smarty.foreach.listingRow.index neq 1}
       <td>{$value}</td>
{/if}
      {/foreach}

lobo
« Last Edit: May 23, 2009, 07:41:15 pm by Donald 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

farmrchrys

  • I post occasionally
  • **
  • Posts: 92
  • Karma: 2
    • Spokane Moves to Amend the Constitution (under development)
  • CiviCRM version: CiviCRM 4.4.6
  • CMS version: Drupal 7.31
  • MySQL version: MySQL 5.5.37
  • PHP version: PHP 5.3.28
Re: How do I Remove Sort Name from Profile Search Results?
May 24, 2009, 06:22:57 am
Yes. Thank you, that works. So the last part of the now looks like this:

Code: [Select]
  {counter start=0 skip=1 print=false}
      {foreach from=$rows item=row name=listings}
      <tr id="row-{$smarty.foreach.listings.iteration}" class="{cycle values="odd-row,even-row"}">
      {foreach from=$row item=value name=listingRow}
{if $smarty.foreach.listingRow.index neq 0 AND $smarty.foreach.listingRow.index neq 1}
       <td>{$value}</td>
{/if}
     
      {/foreach}
      </tr>
      {/foreach}
    </table>

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: How do I Remove Sort Name from Profile Search Results?
May 24, 2009, 01:10:46 pm
Hi,

I tend to prefer testing on the name instead of the position. eg : (I added a link on the name and an edit button before in that example)

Code: [Select]
      {foreach from=$rows item=row key=name name=listings}
      <tr id="contact_{$row.cid}" class="{$row.contact_type} {cycle values="odd-row,even-row"}">

      {foreach from=$row item=value key=name}
{if $name == "sort_name"}
<td class="edit">
<a href="/civicrm/profile/edit?reset=1&gid={$groupId}&id={$row.cid}" class='edit'>edit</a>
</td>
        <td class="{$name}"><a href="/civicrm/profile/view?reset=1&gid={$groupId}&id={$row.cid}">{$value}</a></td>
{else}
        <td class="{$name}">{$value}</td>
{/if}
      {/foreach}
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: How do I Remove Sort Name from Profile Search Results?
May 24, 2009, 05:06:09 pm
actually xavier's method is much better and recommended :) Using index was a bad hack to begin with :(

lobo
« Last Edit: May 24, 2009, 08:45:44 pm by Donald 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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • How do I Remove Sort Name from Profile Search Results?

This forum was archived on 2017-11-26.