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) »
  • Customize contact profile look and feel (Drupal)
Pages: [1] 2

Author Topic: Customize contact profile look and feel (Drupal)  (Read 4847 times)

yaunus

  • I’m new here
  • *
  • Posts: 13
  • Karma: 0
Customize contact profile look and feel (Drupal)
September 09, 2010, 10:05:00 am
I have a CiviCRM install set up with Drupal. I'm trying to build a completely custom Contact Profile. I've figured out how to use the API to pull contact data from CiviCRM, but it only includes the basic data, not any custom data fields I've set up.

How can I access the custom data fields? Here's the code I'm using that is not working:

Code: [Select]
function sncr_civicrm_contact_get($contact_id) {

    require_once 'api/v2/Contact.php';
    require_once 'api/UFGroup.php';
    civicrm_initialize(TRUE);
   
    require_once 'CRM/Custom/Form/CustomData.php';
    CRM_Custom_Form_CustomData::preProcess();

    $retrieve = array( 'contact_id' => $contact_id  );

    $results = civicrm_contact_get($retrieve);
    return $results[$contact_id];
 
}

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Customize contact profile look and feel (Drupal)
September 11, 2010, 03:23:32 am
Hi,

You know you can override the profile template per profile ?
(eg put in your template override CRM/Profile/Form/{profileid}/Edit.tpl and that's what is taken).

Might be much easier to do it that way. What's the aim of your custom profile ?

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

yaunus

  • I’m new here
  • *
  • Posts: 13
  • Karma: 0
Re: Customize contact profile look and feel (Drupal)
September 23, 2010, 01:41:51 pm
I'm trying to completely customize the look and feel of the profile page to display certain member types in a Member Directory on my site. I need to be able to pull custom profile fields that I've created. How would I go about this?

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Customize contact profile look and feel (Drupal)
September 23, 2010, 06:02:43 pm
i am not sure what you mean by 'profile page' - have you considered using Views if you are trying to make a Member Directory?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

dwatts3624

  • Guest
Re: Customize contact profile look and feel (Drupal)
October 13, 2010, 07:12:46 am
I've run into this same requirement and am having some difficulty aligning the documentation with what I'm actually trying to accomplish.

I'm running CiviCRM 3.2 with Drupal 6.19 and have views2, cck, etc. installed.

The documentation I've been referencing is primarily:
http://wiki.civicrm.org/confluence/display/CRMDOC32/Profiles+Admin
http://wiki.civicrm.org/confluence/display/CRMDOC32/Customize+Built-in,+Profile,+Contribution+and+Event+Registration+Screens

Which references "CRM/Contact/Page/View/Summary.tpl" but that file looks like it has nothing to do with what's displaying on the front-end.

I can see that CiviCRM is loading all of my fields (default & custom) correctly on the profile page (http://www.website.com/users/{user}).  The only Drupal fields seem to be history.

And everything CiviCRM is wrapped in <div id="crm-container" lang="en" xml:lang="en">

So, my question is: how can I customize the layout of this page?  I've gathered how to pull a specific field from the CiviCRM documentation but don't know which .tpl file I should be overriding and which part of the file I need to edit.

Since starting this thread I've seen:
CRM/Profile/Page/View.tpl
CRM/Profile/Page/Dynamic.tpl
CRM/Profile/Page/Overlay.tpl

Am I on the right track?  Any assistance or further direction would be greatly appreciated.

Thank you in advance!

Danny

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: Customize contact profile look and feel (Drupal)
October 13, 2010, 11:26:14 am

i'm pretty sure u need to modify:

CRM/Profile/Page/Dynamic.tpl

you might want to check and ensure you are on the drupal users page for your mods (since that template is used in other places also)

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

dwatts3624

  • Guest
Re: Customize contact profile look and feel (Drupal)
October 13, 2010, 04:28:00 pm
Thanks for the quick follow-up!

As you can tell, I'm a bit of a noob.  I've been following CiviCRM for a while and have been really excited about it! ...just need to figure out some of these common tasks related to the website site of things.

I'm looking at the CRM/Profile/Page/Dynamic.tpl file and see this comment on line 172:

// $profileFields array can be used for customized display of field labels and values in Profile/View.tpl

...which conflicts a bit with what you're saying.  What part of this file should I modify?  Also, are there any examples of this?  It seems like it would be common.

Also, since the file controls other aspects of the system, do you mean writing logic into what will be my new code to "check" if it's a profile page?  How and where should I do that?

I noticed in the profile admin that it's possible to create custom templates per contact type.  Is that something I should be doing?  And does it work for the profile files?

Since the contact documentation says to create: /CRM/Contact/Page/View/SubType/subTypeFile.tpl (I guess I don't understand the the difference between the "contact" and "profile" template).

If this is all documented somewhere and I'm completely missing something let me know.  I hate to waste anyone's times with redundant information.

Thank you again!

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Customize contact profile look and feel (Drupal)
October 13, 2010, 04:34:16 pm
Danny - I saw you mentioned you had Views - have you looked at doing what you want through that option?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

dwatts3624

  • Guest
Re: Customize contact profile look and feel (Drupal)
October 13, 2010, 05:07:16 pm
I'll definitely be using views to display the profiles in a listing format once I get this profile thing figured out but hadn't considered using views to display the profiles themselves.  Honestly, I've been learning Drupal alongside CiviCRM so there's a ton I still don't know.  My background is really in Joomla & Typo3.

Any suggestions on how to get started w/that?  I guess using the username or something unique to a user as an argument?

What about the CiviNode plug-in?  I guess I could sync the fields and use CCK too.

I'm open to any solutions! :)

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Customize contact profile look and feel (Drupal)
October 13, 2010, 05:13:11 pm
Outline what you want your View to be showing - then i may be able to offer some pointers
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

dwatts3624

  • Guest
Re: Customize contact profile look and feel (Drupal)
October 13, 2010, 05:28:35 pm
I really appreciate the help. 

It should be a pretty simple layout...

The list would be a name, photo & 2-3 custom fields.  I was also going to use arguments to filter the profiles by chapter (eg. "Orlando", "Tampa", "South Florida")

The profiles would be the same fields (arranged differently) with a 500-or-so character bio and, hopefully, contact information displayed to logged in users (like it does now with the default functionality).

I have a general idea of how to do this with CCK nodes and views but am completely lost when CiviCRM is introduced into the equation.

Thank you again!

dwatts3624

  • Guest
Re: Customize contact profile look and feel (Drupal)
October 15, 2010, 05:44:09 am
Hello again,

I re-read this document and think that creating custom .tpl files is the best solution:
http://wiki.civicrm.org/confluence/display/CRMDOC32/Customize+Built-in,+Profile,+Contribution+and+Event+Registration+Screens

Also, FYI, the profile layout I was hoping to configure goes a bit beyond the default display or anything I could do by overriding CSS.  The fields I need are actually already displaying, just not where and how I wanted them to.

For example, I might have something like:

<div class="col1">{photo}</div>
<div class="col2">
<p>{fname} "{member-nickname}" {lname} {member-roman-numeral}</p>
<p>{member-bio}</p>
</div>
<div>{user-only-contact-info}</div>

So, any help with what I need to edit in the following files would be incredibly helpful...

CRM/Profile/Page/View.tpl
CRM/Profile/Page/Dynamic.tpl

For any of the CiviCRM contributers out there, I'll be happy to document this solution once I can get some direction since there doesn't seem to be any information related to it currently.

Thanks again!

Danny

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: Customize contact profile look and feel (Drupal)
October 15, 2010, 07:01:18 am

here are some examples where i've modified the profile pages a fair amount:

http://svn.civicrm.org/sfschool/branches/v3.2/templates/CRM/Profile/

you can take a look there to see how to change look and feel / add new stuff / replace it completely with your own markup and layout

the 2 important things are:

1. For a specific profile, you know all the fields in it, and hence can call by name

2. Modify specific profile pages (using profile id) rather than all profiles

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

dwatts3624

  • Guest
Re: Customize contact profile look and feel (Drupal)
October 15, 2010, 08:16:55 am
That's perfect!  Exactly what I was looking for.

Thank you!

dwatts3624

  • Guest
Re: Customize contact profile look and feel (Drupal)
October 16, 2010, 12:06:46 pm
I was able to customize the CiviCRM fields in my Drupal profiles by editing the dynamic.tpl file under a directory name to the profile ID.

For anyone referencing this thread, I ended up using {$profileFields.first_name.value} to display a custom field.  For some reason {$profileFields_ID.first_name.value} ({$profileFields_1.first_name.value} for profile ID 1) as the documentation suggests didn't work.

lobo, is there a way to pull the URL field from image_URL versus {$profileFields.image_URL.value} which produces the default HTML (without modifying CiviCRM's core)?

I was hoping to display larger images in the profiles.

Danny

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Customize contact profile look and feel (Drupal)

This forum was archived on 2017-11-26.