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) »
  • Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
Pages: [1]

Author Topic: Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl  (Read 2877 times)

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
February 19, 2009, 06:10:58 pm
Thanks for reading.  When we use a field in a Profile we can add some Field Help.  I'd like to display this field help on the "view" page of a profile.  However, when I look at the _customdir_/CRM/Profile/Page/View.tpl file I don't see where the fields are pulled from the database.

Any suggestions?  Am I in the wrong file?  I am using 2.0.5. (can't upgrade sorry) and this is all I see on View.tpl

Code: [Select]
{foreach from=$profileGroups item=group}
    <h2>{$group.title}</h2>
    {$group.content}
{/foreach}
<div class="action-link">
    <a href="{$listingURL}">&raquo; {ts}Back to Listings{/ts}</a>&nbsp;&nbsp;&nbsp;&nbsp;
    {if $mapURL}
    <a href="{$mapURL}">&raquo; {ts}Map Primary Address{/ts}</a>
    {/if}

</div>
Try CiviTeacher: the online video tutorial CiviCRM learning library.

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: Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
February 19, 2009, 06:19:24 pm

you will need to modify: templates/CRM/Profile/Page/Dynamic.tpl

I think you will also need to modify CRM/Profile/Page/Dynamic.php to expose the help text. I'm pretty sure that the $fields array has the help text, so you can expose that to the template and use that

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

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
February 20, 2009, 05:06:52 pm
Thanks for the response.  But I don't understand enough of what is going on in Dynamic.php to know what to change.  Also I am wondering, if I hack this PHP file, won't it just get overwritten if/when I upgrade CiviCRM?

Here is the file, if you could point out what I need to do please enlighten me

Dynamic.php
Code: [Select]
<?php

/*
 +--------------------------------------------------------------------+
 | CiviCRM version 2.0                                                |
 +--------------------------------------------------------------------+
 | Copyright CiviCRM LLC (c) 2004-2007                                |
 +--------------------------------------------------------------------+
 | This file is a part of CiviCRM.                                    |
 |                                                                    |
 | CiviCRM is free software; you can copy, modify, and distribute it  |
 | under the terms of the GNU Affero General Public License           |
 | Version 3, 19 November 2007.                                       |
 |                                                                    |
 | CiviCRM is distributed in the hope that it will be useful, but     |
 | WITHOUT ANY WARRANTY; without even the implied warranty of         |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
 | See the GNU Affero General Public License for more details.        |
 |                                                                    |
 | You should have received a copy of the GNU Affero General Public   |
 | License along with this program; if not, contact CiviCRM LLC       |
 | at info[AT]civicrm[DOT]org. If you have questions about the        |
 | GNU Affero General Public License or the licensing of CiviCRM,     |
 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
 +--------------------------------------------------------------------+
*/

/**
 *
 * @package CRM
 * @copyright CiviCRM LLC (c) 2004-2007
 * $Id$
 *
 */

require_once 'CRM/Core/Page.php';

/**
 * Create a page for displaying CiviCRM Profile Fields.
 *
 * Heart of this class is the run method which checks
 * for action type and then displays the appropriate
 * page.
 *
 */
class CRM_Profile_Page_Dynamic extends CRM_Core_Page {
    
    
/**
     * The contact id of the person we are viewing
     *
     * @var int
     * @access protected
     */
    
protected $_id;

    
/**
     * the profile group are are interested in
     * 
     * @var int 
     * @access protected 
     */ 
    
protected $_gid;

    
/**
     * The profile types we restrict this page to display
     *
     * @var string
     * @access protected
     */
    
protected $_restrict;

    
/**
     * Should we bypass permissions
     *
     * @var boolean
     * @access prootected
     */
    
protected $_skipPermission;

    
/**
     * class constructor
     *
     * @param int $id  the contact id
     * @param int $gid the group id
     *
     * @return void
     * @access public
     */
    
function __construct( $id, $gid, $restrict, $skipPermission = false ) {
        
$this->_id       = $id;
        
$this->_gid      = $gid;
        
$this->_restrict = $restrict;
        
$this->_skipPermission = $skipPermission;

        
parent::__construct( );
    }

    
/**
     * Get the action links for this page.
     *
     * @return array $_actionLinks
     *
     */
    
function &actionLinks()
    {
        return 
null;
    }
    
    
/**
     * Run the page.
     *
     * This method is called after the page is created. It checks for the  
     * type of action and executes that action. 
     *
     * @return void
     * @access public
     *
     */
    
function run()
    {
        
$template =& CRM_Core_Smarty::singleton( ); 
        if ( 
$this->_id && $this->_gid ) {
            require_once 
'CRM/Core/BAO/UFGroup.php';

            
$values = array( );
            
$fields = CRM_Core_BAO_UFGroup::getFields( $this->_gid, false, CRM_Core_Action::VIEW,
                                                       
null, null, false, $this->_restrict, $this->_skipPermission );

            
// make sure we dont expose all fields based on permission
            
$admin = false; 
            
$session  =& CRM_Core_Session::singleton( ); 
            if ( 
CRM_Core_Permission::check( 'administer users' ) || 
                 
$this->_id == $session->get( 'userID' ) ) { 
                
$admin = true; 
            }

            if ( ! 
$admin ) {
                foreach ( 
$fields as $name => $field ) {
                    
// make sure that there is enough permission to expose this field 
                    
if ( $field['visibility'] == 'User and User Admin Only' ) {
                        unset( 
$fields[$name] );
                    }
                }
            }
            
CRM_Core_BAO_UFGroup::getValues( $this->_id, $fields, $values );

            
$template->assign_by_ref( 'row', $values );
        }
        return 
trim( $template->fetch(  $this->getTemplateFileName( ) ) );
    }

    function 
getTemplateFileName() {
        if ( 
$this->_gid ) {
            
$templateFile = "CRM/Profile/Page/{$this->_gid}/Dynamic.tpl";
            
$template     =& CRM_Core_Page::getTemplate( );
            if ( 
$template->template_exists( $templateFile ) ) {
                return 
$templateFile;
            }
        }
        return 
parent::getTemplateFileName( );
    }

}

?>

Try CiviTeacher: the online video tutorial CiviCRM learning library.

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: Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
February 20, 2009, 05:30:29 pm

Yes it will get overwritten with a new version. You will need to manage a diff set and figure out a process to merge your changes

Add:

$template->assign_by_ref( 'fields', $fields );

below the other assgn statement. Also look at Form/Dynamic.tpl and use something similar to display the field help

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

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
February 20, 2009, 08:00:58 pm
Thank you much for the help.  Although I've been doing PHP/MySQL for about 7 years, I'm sorry but I don't understand what you mean I should do with the .tpl file - I guess I just don't "get it" - I'm SORRY!

After making the changes in the .php file you recommend
I tried this:
Code: [Select]
{foreach from=$fields item=value key=name}
  <tr><td class="label">{$name}</td><td class="view-value">{$value}</td></tr>
{/foreach}

which copies this:
{foreach from=$row item=value key=name}
  <tr><td class="label">{$name}</td><td class="view-value">{$value}</td></tr>
{/foreach}
but that doesn't do anything but display "Array" on the page like this: http://rivernetwork.org/rn/civicrm/profile/view?reset=1&id=38575&gid=7

I tried a bunch of other experiments by trial and error for about 1 hour, banging my head against the wall -- so don't think that I'm lazy please.  Maybe I'm just stupid.  How can I get the "help" field on the page on there?  How do I edit Dynamic.tpl file?

« Last Edit: February 20, 2009, 08:03:34 pm by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

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: Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
February 20, 2009, 08:34:14 pm

here is a diff file which is close to what you need:

Code: [Select]
Index: CRM/Profile/Page/Dynamic.php
===================================================================
--- CRM/Profile/Page/Dynamic.php        (revision 19996)
+++ CRM/Profile/Page/Dynamic.php        (working copy)
@@ -144,7 +144,13 @@
             }
             CRM_Core_BAO_UFGroup::getValues( $this->_id, $fields, $values );
 
-            $template->assign_by_ref( 'row', $values );
+            $help = array( );
+            foreach ( $fields as $n => $v ) {
+                $help[$v['title']] = $v['help_post'];
+            }
+
+            $template->assign_by_ref( 'row' , $values );
+            $template->assign_by_ref( 'help', $help );
         }
         return trim( $template->fetch(  $this->getTemplateFileName( ) ) );
     }
Index: templates/CRM/Profile/Page/Dynamic.tpl
===================================================================
--- templates/CRM/Profile/Page/Dynamic.tpl      (revision 19996)
+++ templates/CRM/Profile/Page/Dynamic.tpl      (working copy)
@@ -5,6 +5,10 @@
 <table class="form-layout-compressed">                               
 {foreach from=$row item=value key=rowName name=profile}
   <tr id="row-{$smarty.foreach.profile.iteration}"><td class="label">{$rowName}</td><td class="view-value">{$value}</td></tr>
+{if $help.$rowName}
+  <tr id="help-{$smarty.foreach.profile.iteration}"><td>&nbsp;</td><td class="view-value"><small>{$help.$rowName}</small></td></tr>
+   
+{/if}
 {/foreach}
 </table>
 </fieldset>

this diff is against 2.2, but should be close to the 2.1 code base. adapt as needed

in exchange for the above, you can help out by answering a few forum posts for the next few days

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

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
February 21, 2009, 04:39:38 pm
Thanks for posting that -- I was way off!

Anyhow I will respond to a few help requests in the coming weeks, where I am qualified to do so, thanks again.
Try CiviTeacher: the online video tutorial CiviCRM learning library.

ds505

  • I post occasionally
  • **
  • Posts: 40
  • Karma: 3
Re: Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl
April 10, 2009, 11:46:41 am
For some reason, I couldn't get the above method to work, but I found another way (tested on CiviCRM 2.0).

In CRM/Profile/Form/Search.tpl, use {$fields.$n.help_post} to get the help text to appear underneath each criteria box. I added it as follows (approx line 58):

               
Code: [Select]
<td class="description">{$form.$n.html}<br>{$fields.$n.help_post}</td>

Thanks,
LJ
Data-Scribe(r)
http://www.datascribe.biz

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Displaying "Field Help" on this .tpl file: /CRM/Profile/Page/View.tpl

This forum was archived on 2017-11-26.