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) »
  • Custom profile view - I must be missing something?
Pages: [1] 2

Author Topic: Custom profile view - I must be missing something?  (Read 6029 times)

mhm

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
Custom profile view - I must be missing something?
February 21, 2010, 07:15:13 pm
I'm setting up a membership directory using CiviCRM.  Current progress has been fine, although I don't like the display. 
Here's where I'm at currently:  http://test.azmuseums.org/civicrm/profile?force=1&gid=10

I'd like to combine the name and website into one cell of the display, and combine the address, city, and zip into another cell. 

I think this should be possible, right? 

I've looked at the instructions at http://wiki.civicrm.org/confluence/display/CRMDOC/Customize+Built-in%2C+Profile%2C+Contribution+and+Event+Registration+Screens and I just feel very lost. I'm new to Smarty, and their page didn't help me at all.  I think I understand the concept, but I'm obviously missing something between the concept, and the execution. 

Is there somewhere I can find a bit more detailed walkthrough of what I need to change?  I think I need to create a custom Listings.tpl, but from there I'm a bit lost.
It looks like this is the chunk of code I need to edit:
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>

Where do I get the tokens to change this table?
Help!?

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: Custom profile view - I must be missing something?
February 21, 2010, 07:25:27 pm
You may be able to better realise your dreams by going down the Views path in drupal - though not sure what trips there might be re the image or map yet.
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

mhm

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
Re: Custom profile view - I must be missing something?
February 21, 2010, 07:46:36 pm
Yeah, that was this morning's attempt  ;)

The image did present an issue, and so it started to look like this might be easier solved within CiviCRM.

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: Custom profile view - I must be missing something?
February 21, 2010, 07:59:50 pm

1. customize that specific proile template, i.e. gid=10

2. check: http://wiki.civicrm.org/confluence/display/CRMDOC/Customizing+CiviCRM+Screens

for some general tips and techniques

3. with debugging turned on, add smartyDebug=1 which will give you a popup window with all the smarty variables exposed. The website url is called home_URL etc. you can merge those two columns (check if it has a value and make that conditional) and also the street/city/zip in another column

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

mhm

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
Re: Custom profile view - I must be missing something?
February 21, 2010, 08:32:01 pm
You save me every time!  Now I have a gameplan for how to resolve this next weekend. Thanks!

mhm

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
Re: Custom profile view - I must be missing something?
February 28, 2010, 09:28:53 pm
Okay, I think I'm on the right track, but I'm not getting things exactly right. I currently have a new table (the one I'm messing with) above the default, if anyone needs a visual to be able to point me where I need to go.

Basically, it's sizing the cells correctly (width-wise, anyway), but it's not adding any content to them. I'm quite certain I've got something wrong with the /foreach part of the argument, but if I remove it, things get worse.  Based on what I know about data merges, this should be required so that it fills the data in as requested for each cell, on to the end.

Given that this is a merge into a table, my theory is that there should simply be something to call the specific type of data ({$profileFields_10.sort_name.value} and so forth), and something to tell it to fill the appropriate data in automatically for each field. 

Here's what I've got:
Code: [Select]
<table>
<tr class="columnheader">
<td>Museum, website</td>
<td> Photo</td>
<td> Address </td>
<td> Phone </td>
<td> </td></tr>
<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>{$profileFields_10.sort_name.value}<br>
{$profileFields_10.home_URL.value}</td>
<td>{$profileFields_10.custom_1.value}</td>
      {/foreach}
      </tr>
      {/foreach}</tr>
</table>

(I haven't filled the whole thing in, as what I've got so far doesn't even work.)

Is the proper syntax something I should be able to find in Smarty documentation?

mhm

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
Re: Custom profile view - I must be missing something?
March 08, 2010, 05:27:59 pm
Okay, so this is failing miserably.
I went through part of the Smarty handbook, and still couldn't figure this out.  No matter I what I do, it won't actually print the required information to the screen. It might put in space for that information, but that's as close as I can get.
Help?

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: Custom profile view - I must be missing something?
March 08, 2010, 08:29:22 pm

check the templates in:

http://svn.civicrm.org/sfschool/trunk/templates/CRM/Profile/

for examples of custom profile templates. For more specific help, best to contact us on IRC (http://webchat.freenode.net/?channels=#civicrm)

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

cincyKid

  • Guest
Re: Custom profile view - I must be missing something?
March 26, 2010, 09:04:56 am
Hello ~

I was wondering mhm if you ever got this working?  I have been trying to do the same (almost exact same thing) for some time now.  After 2 days of researching, reading and trying different things I am still at a loss.

I am trying to have my directory look something like this:

Company Name
Address
city, state, zip

I know I can turn debuggin on and use smartyDebug=1 to show me the field names i need to grab.  The problem is the syntax and what steps need to be taken to diplay the data on the listings.tpl page.

I have tried different things, but the latest I have tried is this:

1) Added the lines of code to Dynamic.php as suggested in this thread: :
 http://forum.civicrm.org/index.php?action=printpage;topic=9037.0

Code: [Select]
CRM_Core_BAO_UFGroup::getValues( $this->_id, $fields, $values );

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

            $profileFields = array( );
            $labels = array( );

            foreach ( $fields as $name => $field ) {
                $labels[$field['title']] = preg_replace('/\s+|\W+/', '_', $name);
            }

            foreach ( $values as $title => $value ) {
                $profileFields[$labels[$title]] = array( 'label' => $title,
                                                    'value' => $value );

            }

            $template->assign_by_ref( 'profileFields_' . $this->_gid, $profileFields );

            $template->assign_by_ref( 'row', $values );


I have tried commenting out the last line and also leaving in with the same result for both:
 $template->assign_by_ref( 'row', $values );

Because I wasn't sure if it was supposed to stay in place or not with the added code.




2) Modified the code in Listings.tpl just to see if I could get any value to spit out on the screen

so I added the line:
{$profileFields_19.last_name.value}

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=listings}        
        {if $smarty.foreach.listings.iteration EQ 6}
         <td><a href='mailto:{$value}'>{$value}</a><br>{$profileFields_19.last_name.value}</td>
        {else}
        <td>{$value}</td>
        {/if}
      {/foreach}
      </tr>
      {/foreach}

The other code you see in there for the email address was somethign Dave helped me with some time ago in this thread: http://forum.civicrm.org/index.php/topic,3145.0.html

So Im not sure if that will need to be changed too or if its good to stay that way (since it does work).


Thats pretty much it.  I just need to find out how to get those variable values into the Listings.tpl page so that i can format them in a table or however i want it to appear in the directory.

HELP! :)

Any advice or direction would be much appreciated!

« Last Edit: March 26, 2010, 09:08:15 am by cincyKid »

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Custom profile view - I must be missing something?
March 26, 2010, 04:07:52 pm
Your best bet for figuring this out is to make sure you can see the variables that have been assigned / are available to the template. If you add this line to the top of your customized template (and have Debugging enabled under Administer >> Global Settings) - you'll get a nice pop-up in your browser listing all the variables:

Code: [Select]
{debug}
Protect your investment in CiviCRM by  becoming a Member!

cincyKid

  • Guest
Re: Custom profile view - I must be missing something?
March 27, 2010, 05:29:05 am
Hello Dave,

Thanks for the reply.

As I mention above, I have done the debugging and seen the pop up window with all of the variable / field names / etc.

The question is, is it possible to get those variable values in my listings template to show up without having the hack mentioned here: http://forum.civicrm.org/index.php?action=printpage;topic=9037.0

In IRC, dlobo said the hack is to be included in version 3.x.

With me using 2.2 can it be done?  If so whats the syntax I use in listings.tpl to get them to show up

This will not work for me:

{$profileFields_19.last_name.value}

Thanks again Dave, really hoping to figure this out!
« Last Edit: March 27, 2010, 05:31:08 am by cincyKid »

cincyKid

  • Guest
Re: Custom profile view - I must be missing something?
March 29, 2010, 10:27:52 am
***UPDATE***

So I compared the Dynamic.php file from the current release to the Dynamic.php file I am using in 2.2 and the newer one did have the hack mentioned above included, so I added the lines to my Dynamic.php file.

Then, I open my View.tpl file and i type this near the top:

Code: [Select]
{$profileFields_19.last_name.label} {$profileFields_19.last_name.value}

And it spits it out (label and value)!

Last Name Smith

if only this were the Listings.tpl page!

dlobo said  "make a similar change in CRM/Profile/Page/Listings.php"

I tried adding the code from Dynamic.php to a couple places in Listings.php to see if it would work but it does not allow me to spit out values on the Listings.tpl page, so I am sure the code I need to add to Listings.php is different and not sure what to do.

Any other ideas?  Is it really this hard to get values to dispaly on the  profile listings page??
« Last Edit: March 29, 2010, 10:33:59 am by cincyKid »

cincyKid

  • Guest
Re: Custom profile view - I must be missing something?
March 30, 2010, 06:16:12 am
I know this has to be possible and shouldn't be as hard as it seems.

I have tried using this code insde Listings.php

Code: [Select]
$fields = CRM_Core_BAO_UFGroup::getListingFields( CRM_Core_Action::VIEW,
                                                          CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY |
                                                          CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY,
                                                          false, $gid );  
// been trying the code right here in this file - also this next line I have tried with and also commenting out

//CRM_Core_BAO_UFGroup::getValues( $gid, $fields, $values );

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

            $profileFields = array( );
            $labels = array( );

            foreach ( $fields as $name => $field ) {
                $labels[$field['title']] = preg_replace('/\s+|\W+/', '_', $name);
            }

            foreach ( $values as $title => $value ) {
                $profileFields[$labels[$title]] = array( 'label' => $title, 'value' => $value );

            }

$template->assign_by_ref( 'row', $values );
$template->assign_by_ref( 'profileFields_' . $gid, $profileFields );



// this is where the code I added stops

        $returnProperties =& CRM_Contact_BAO_Contact::makeHierReturnProperties( $fields );
        $returnProperties['contact_type'] = 1;
        $returnProperties['sort_name'   ] = 1;

And I have tried multiple different things in Listings.tpl to get any of these variables to spit out their values but none are working in this syntax

Code: [Select]
{$profileFields_19.last_name.value}

{$profileFields_19.custom_15.value}

etc.

Can anyone help me out here?

thanks again

cincyKid

  • Guest
Re: Custom profile view - I must be missing something?
March 30, 2010, 07:54:38 am
*** UPDATE ***

I thought I would post a screenshot of what I am tryign to accomplish:
http://slydragonfly.com/files/directory.jpg

I just need a way to put the full addresses under the name and also under the company name.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Custom profile view - I must be missing something?
March 30, 2010, 11:06:17 am
The easy way to do this is to basically hard-code the table elements in Listings.tpl. Again, use your smarty debug window to check the contents of the $rows variable (which has all your results data in some arrays). Then you can comment out the inner foreach loop, and replace with hardcoded set of columns. Quick example of hard-coding the first cell with sort_name, city ($row.1 in my profile), and country ($row.2). For the table column headers, you'll need to do something similar (or use some {if} statements to skip header columns you don't need).

HTH

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"}">
      {* (skip this inner looping ) foreach from=$row item=value}
        <td>{$value}</td>
      {/foreach*}
        <td>{$row.sort_name}<br />{$row.1}, {$row.2}</td>
      </tr>
      {/foreach}
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1] 2
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Custom profile view - I must be missing something?

This forum was archived on 2017-11-26.