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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Hide Column fields and header sort in custom .tpl
Pages: [1]

Author Topic: Hide Column fields and header sort in custom .tpl  (Read 2614 times)

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Hide Column fields and header sort in custom .tpl
March 20, 2008, 09:39:12 am
I am making a custom form for an activity search, but there are a few pieces I am stuck on.

1. Because I have to expose an activity id in order to link to an activity, I then want to hide the activity id row on my custom .tpl file. I can just not use a header title, but the sort arrows still show up. How can I make them disappear? Can I do this in the custom search file, or do I have to do it in the template in this area:

Code: [Select]
<tr class="columnheader">
  <th scope="col" title="Select All Rows">{$form.toggleSelect.html}</th>
  {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}
  <th>&nbsp;</th>
  </tr>


2. I am trying to hide the activity id column completely, so I need it to not display the data. This might be a Smarty syntax question; not sure. So here is what I have, but how do I say "skip this field" or "don't display anything" in smarty?

Code: [Select]
{if $fName eq 'activity_id'}

{elseif $fName eq 'activity_type_id'}
           
{else}
 <td>{$row.$fName}</td>

3. Right now I am linking my activities to a page with these parameters:

Code: [Select]
{elseif $fName eq 'activity_subject'}
            <td><a href="{crmURL p='civicrm/contact/view/activity' q="atype=`$row.activity_type_id`&action=view&reset=1&id=`$row.activity_id`&cid=`$row.contact_id`&context=home"}">{$row.activity_subject}</a></td>

But I don't think that's actually where I want to go, as it puts a "Done" button on the page which in turn takes you back to the main dashboard (instead of back to the search listings). Is there a way that I can have the link open the contact summary page directly to the activities tab? If not, can I have it go directly to this activitiy but have the "Done" button take me back to the search listings?

Thanks very much for the assistance.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Hide Column fields and header sort in custom .tpl
March 23, 2008, 02:05:17 am
Hi,

Here is what I did for the header:
Code: [Select]
    {if ($header.sort eq 'contact_id') or ($header.sort eq 'employer_id')}
    {else}
            <th scope="col">
            {if $header.sort}
              {assign var='key' value=$header.sort}
              {$sort->_response.$key.link}
            {else}
              {$header.name}
            {/if}
            </th>
    {/if}

And for each column (I don't display the columns contact_id and employer_id)

Code: [Select]
      {foreach from=$rows item=row}
        <tr id='rowid{$row.contact_id}' class="{cycle values="odd-row,even-row"}">
          {assign var=cbName value=$row.checkbox}
          <td>{$form.$cbName.html}</td>
          {foreach from=$columnHeaders item=header}
            {assign var=fName value=$header.sort}
            {if ($fName eq 'first_name') or ($fName eq 'last_name')}
                    <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.$fName}</a></td>
            {elseif ($fName eq 'contact_id') or ($fName eq 'employer_id')}
            {elseif $fName eq 'employer'}
                    <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.employer_id`"}">{$row.$fName}</a></td>
            {else}
                    <td>{$row.$fName}</td>
            {/if}
          {/foreach}
          <td>{$row.action}</td>
        </tr>
     {/foreach}

And the column isn't displayed.

For the point 3, I don't know.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Hide Column fields and header sort in custom .tpl
March 24, 2008, 11:45:54 am
It looks like linking to the Activity Tab is the best way to go now. Otherwise you need to set the "userContext" for the View Activity form to tell it go go back to your search results when Done is clicked - and I don't know of a way to do that w/o adding a parameter and modifying View Activity's php page code to use it.

I think this code will get you to the contact's activity tab - and the "Search Results" breadcrumb should go back to the custom search results listing:

Code: [Select]
{crmURL p='civicrm/contact/view' q="action=browse&selectedChild=activity&reset=1&cid=`$row.contact_id`"}
Protect your investment in CiviCRM by  becoming a Member!

emilyf

  • Ask me questions
  • ****
  • Posts: 696
  • Karma: 54
  • CiviCRM version: 2.x - 4.x
  • CMS version: Drupal 5, 6, 7
Re: Hide Column fields and header sort in custom .tpl
March 28, 2008, 12:21:27 pm
Thank you both. Everything works perfectly now!

FYI to anyone who is interested, this custom search will be part of the next minor release. You will still need to register the custom search component on this one until 2.1 comes out, but that is very easy and is documented here:

http://wiki.civicrm.org/confluence/display/CRMDOC/Custom+Search+Components

You will also need to create a custom template file if you want to hide rows like I did. I will be posting my documentation for this on the same wiki page as above :)

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: Hide Column fields and header sort in custom .tpl
March 28, 2008, 01:50:52 pm

This is now part of 2.0.2 which should be released next week

thanx for the contrib emily :)

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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Hide Column fields and header sort in custom .tpl

This forum was archived on 2017-11-26.