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) »
  • How to change order of dashboard elements on the Contact Dashboard
Pages: [1]

Author Topic: How to change order of dashboard elements on the Contact Dashboard  (Read 1665 times)

mdavid

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.2.17
How to change order of dashboard elements on the Contact Dashboard
February 13, 2011, 01:40:57 am
How can I change the order of the dashboard elements on the user's Contact Dashboard?

They currently display in this order:
Your Groups
Your Contributions
Your Events
Your Memberships

I need them to display in this order:
Your Memberships
Your Groups
Your Events
Your Contributions

I looked at creating a custom UserDashBoard.tpl, but it has a foreach loop for the dashboard elements.

I looked at creating a hook_civicrm_dashboard, but I don't want to replace the dashboard content, I simply want to reorder it.

I also looked at UserDashBoard.php, but I don't see what is controlling the order of the elements.

Where is the order of the dashboard elements being set? How can it be changed?

Thanks.
« Last Edit: February 13, 2011, 01:42:58 am by mdavid »

Rahul Bile

  • I post occasionally
  • **
  • Posts: 112
  • Karma: 16
  • impossible says, I M Possible
    • I AM POSSIBLE
Re: How to change order of dashboard elements on the Contact Dashboard
February 13, 2011, 03:55:30 am
 mdavid,

in CRM/Contact/Page/View/UserDashboard.php.  at line number 179 , $dashboardElements holds the array of all the elements.  You can modify the array as per your requirement before assigning to tpl. ( i.e before $this->assign ( 'dashboardElements', $dashboardElements );  )

HTH

Rahul

Consider donating to CiviCRM if you use it. http://civicrm.org/donate

mdavid

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.2.17
Re: How to change order of dashboard elements on the Contact Dashboard
February 14, 2011, 02:32:55 pm
Hi Rahul,

Thanks. I see the line you reference and have now read through the CRM/Utils/Sort.php which is called right above it. The default sort order in CRM_Utils_Sort is ascending. I tried changing it to sort in descending order, but couldn't get it to work.

I'm still new at PHP and CiviCRM. Can you provide more information or point me to a code snippet or example for how to write the PHP required to modify the array?

Thanks,
 Michael

Rahul Bile

  • I post occasionally
  • **
  • Posts: 112
  • Karma: 16
  • impossible says, I M Possible
    • I AM POSSIBLE
Re: How to change order of dashboard elements on the Contact Dashboard
February 14, 2011, 09:26:03 pm
Michael,

$dashboardElements have all the entries of component elements (event,member,contribution). But it do not contains group(s) as groups is not a different component.
As you requirement order is
Your Memberships
Your Groups
Your Events
Your Contributions
I would suggest you to have changes in tpl rather than PHP file.
( templates/CRM/Contact/Page/View/UserDashBoard.tpl )

You can try the below code in you tpl file.
Code: [Select]
<table class="dashboard-elements">
 <tr>
        <td>
            <div class="header-dark">Your Membership(s)</div>        
            {include file=CRM\Member\Page\UserDashboard.tpl}
        </td>
    </tr>

{if $showGroup}
    <tr>
        <td>
          <div class="header-dark">
          {ts}Your Group(s){/ts} 
          </div>  
          {include file="CRM/Contact/Page/View/UserDashBoard/GroupContact.tpl"}
           
        </td>
    </tr>
{/if}
<tr>
        <td>
            <div class="header-dark">Your Event(s)</div>        
            {include file=CRM\Event\Page\UserDashboard.tpl}
        </td>
    </tr>
<tr>
        <td>
            <div class="header-dark">Your Contribution(s)</div>        
            {include file=CRM\Contribute\Page\UserDashboard.tpl}
        </td>
    </tr>
</table>


Note: I have just removed the foreach and changed it as per your order ( Memberships, Group, Event etc..  ). when you enable the other components there may be more elements in it which you may need to add as per requirement.
eg (  Your Pledge(s), Your Contacts / Organizations etc.  )


HTh

Rahul.
« Last Edit: February 14, 2011, 09:27:55 pm by Rahul Bile »
Consider donating to CiviCRM if you use it. http://civicrm.org/donate

mdavid

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.2.17
Re: How to change order of dashboard elements on the Contact Dashboard
February 15, 2011, 02:27:03 pm
Rahul,

Thanks so much for sharing code and pointing me in the right direction. Your note was a huge help!

When I first used your code, I received several error messages, so I studied it further and made the following changes:

I changed this:
Code: [Select]
{include file=CRM\Member\Page\UserDashboard.tpl}
to this:
Code: [Select]
{include file="CRM/Member/Page/UserDashboard.tpl"}
My changes use forward slashes (/) instead of backslashes (\) and use quotation marks around the file path and name. I made this change for the Your Membership, Your Event(s), and Your Contributions include files. The include file for Your Group(s) worked fine as you have it.

I was not able to get it to work by editing the tpl file in ( templates/CRM/Contact/Page/View/UserDashBoard.tpl ) as you suggested.

I did get it to work when I created a new UserDashBoard.tpl file and put it in my custom templates folder (/sites/all/civicrm_custom/custom_templates/CRM/Contact/Page/View/UserDashBoard.tpl).

If my changes raise any concerns that I might not be aware of, please let me know.

Thanks very much!
 Michael
« Last Edit: February 15, 2011, 02:29:56 pm by mdavid »

Rahul Bile

  • I post occasionally
  • **
  • Posts: 112
  • Karma: 16
  • impossible says, I M Possible
    • I AM POSSIBLE
Re: How to change order of dashboard elements on the Contact Dashboard
February 15, 2011, 07:50:26 pm
Michael,


Quote
I was not able to get it to work by editing the tpl file in ( templates/CRM/Contact/Page/View/UserDashBoard.tpl ) as you suggested.

I did get it to work when I created a new UserDashBoard.tpl file and put it in my custom templates folder (/sites/all/civicrm_custom/custom_templates/CRM/Contact/Page/View/UserDashBoard.tpl).

You have done it perfectly. changes done in  templates/CRM/Contact/Page/View/UserDashBoard.tpl , should also reflect the same, sometimes we need to empty template_c folder to get the new changes reflected. But going the custom changes in core files through custom_php and custom_templates is always recommended. You are on right and perfectly done. I am Glad it helped you!

cheers !!!!

Rahul.
Consider donating to CiviCRM if you use it. http://civicrm.org/donate

mdavid

  • I post occasionally
  • **
  • Posts: 31
  • Karma: 0
  • CiviCRM version: 4.2
  • CMS version: Drupal 7.15
  • MySQL version: 5.1.63
  • PHP version: 5.2.17
Re: How to change order of dashboard elements on the Contact Dashboard
February 16, 2011, 01:15:49 am
Rahul,

Thanks for the confirmation and explanation. I learned a lot from you. Thanks to your help, the Contact Dashboard looks exactly the way I need it to. And now I know how to update it if I need to add additional sections.

Thanks!
 Michael

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • How to change order of dashboard elements on the Contact Dashboard

This forum was archived on 2017-11-26.