HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Adding CPF's (and other data) below users avatar in posts

As per my other modification to remove the popup that appears when you hover over a users name, I like such data to be under the users name, in plane site, rather than in a popup.   Thus I did this bit of modification in order to move the Custom Profile Fields for users down to there.

To start, you need to edit topicview.php.   Look down for this section of code (search for the comment) and replace that section with this:

Code (php)

                // Poster details
                if ((!$is_spacer_post) && (array_key_exists('custom_fields',$_postdetails)))
                {
                      $popup_fields=new ocp_tempcode();
                      $show_cpf=new ocp_tempcode();
                                       
                       foreach ($_postdetails['custom_fields'] as $name=>$value)
                       {
                              if ((!is_null($value['RENDERED'])) && ($value['RENDERED']!==''))
                               
                                    $show_cpf->attach(do_template('OCF_MEMBER_BOX_CUSTOM_FIELD2',array('_GUID'=>'10b72cd1ec240c315e56bc8a0f3a92a1','NAME'=>$name,'VALUE'=>$value['RENDERED'])));
                        }

                                        if (!is_guest($_postdetails['poster']))
                                        {
                                                require_code('ocf_members2');
                                                $poster_details=render_member_box($_postdetails,false,$hooks,$hook_objects,false);
                                        } else
                                        {
                                                if (array_key_exists('ip_address',$_postdetails))
                                                {
                                                        $popup_fields->attach(do_template('OCF_MEMBER_BOX_CUSTOM_FIELD',array('_GUID'=>'d85be094dff0d039a64120d6f8f381bb','NAME'=>do_lang_tempcode('IP_ADDRESS'),'VALUE'=>($_postdetails['ip_address']))));
                                                        $poster_details=do_template('OCF_GUEST_DETAILS',array('_GUID'=>'e43534acaf598008602e8da8f9725f38','CUSTOM_FIELDS'=>$popup_fields));
                                                } else
                                                {
                                                        $poster_details=new ocp_tempcode();
                                                }
                                        }
                                } else
                                {
                                    $show_cpf=new ocp_tempcode();
                                        $poster_details=new ocp_tempcode();
                                }
 

Of course, if you did the mod to remove the popup, the above code will look a bit different as you removed the posterdetails stuff.

Further down at the $rendered_post=do_template …  at the bottom of the list of all the var's it sends to the template, add:

Code (php)

 'SHOW_CPF'=>$show_cpf,
 

Also,  in  sources_custom/ocf_posts2.php, at the bottom of the list of variables passed in do_template, you need to add

Code (php)

'SHOW_CPF'='',
 

To fix an issue in 9.02 (that should already be fixed in later updates), in in ocf_topicview.php look for:

Code (php)

// Any custom fields to show?
$post['custom_fields']=ocf_get_all_custom_fields_match_member($_postdetails['p_poster'],((get_member()!=$_postdetails['p_poster']) && (!has_specific_permission(get_member(),'view_any_profile_field')))?1:NULL,((get_member()==$_postdetails['p_poster']) && (!has_specific_permission(get_member(),'view_any_profile_field')))?1:NULL,NULL,NULL,NULL,NULL,NULL,0,true);
 

and replace it with:

Code (php)

$post['custom_fields']=ocf_get_all_custom_fields_match_member($_postdetails['p_poster'],((get_member()!=$_postdetails['p_poster']) && (!has_specific_permission(get_member(),'view_any_profile_field')))?1:NULL,((get_member()==$_postdetails['p_poster']) && (!has_specific_permission(get_member(),'view_any_profile_field')))?1:NULL,NULL,NULL,NULL,1);
 

Code (php)

 'SHOW_CPF'=>'';
 

You need to make OCF_MEMBER_BOX_CUSTOM_FIELD2.tpl :

Code (php)

 <div>{NAME*}: {VALUE}</div>
 

and in OCF_TOPIC_POST.tpl add the show_cpf line as seen here:

Code (php)

<div class="ocf_topic_poster_more">
            {POST_AVATAR}
           {+START,IF_NON_EMPTY,{POSTER_TITLE}}<div class="ocf_topic_poster_title">{POSTER_TITLE*}</div>{+END}
            {+START,IF_NON_EMPTY,{RANK_IMAGES}}<div class="ocf_topic_poster_rank_images">{RANK_IMAGES}</div>{+END}
            {+START,IF_NON_EMPTY,{SHOW_CPF}}<div class="ocf_topic_poster_title">{SHOW_CPF}</div>{+END}
         </div>
 

Now you can go into the CPF editor under Members in Adminzone, and if you set one to 'view in posts', it will show up below the users avatar, *if* it is set as publicly viewable.  If it is not publicly viewable, only admins and the user himself/herself can see that data.

– note.  I plan to follow this up with adding in a joined data (shorted to month and year), # of posts, and possibly a few other items.  I will probably make the visibility of those items configuration options.

And here is the modification to mentioned in the line above (as I work on it):

Normally in the popup window, besides name it shows # of posts, date joined, etc.  I want to give the option to show those below the avatar, in addition, if 'show ratings as ikes' is on, I want to show the # of likes a person has.   Each will be able to be turned on and off via Configuration->Forums.. ->Show.   To start, we need to add the fields for these config options in the cop_config table, that is done with this sql:

Code

INSERT INTO `ocp_config` (`the_name`, `human_name`, `c_set`, `config_value`, `the_type`, `eval`, `the_page`, `section`, `explanation`, `shared_hosting_restricted`, `c_data`) VALUES
('show_posts', 'SHOW_POSTS', 1, '0', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'SHOW_IN_POSTS', 'CONFIG_OPTION_show_posts', 0, ''),
('show_joined', 'SHOW_JOINED', 1, '0', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'SHOW_IN_POSTS', 'CONFIG_OPTION_show_joined', 0, ''),
('show_likes', 'SHOW_LIKES', 1, '0', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'SHOW_IN_POSTS', 'CONFIG_OPTION_show_likes', 0, ''),
('show_points', 'SHOW_POINTS', 1, '0', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'SHOW_IN_POSTS', 'CONFIG_OPTION_show_points', 0, '')

next in lang_custom/EN/config.ini, you need to add these:

Code

SHOW_POSTS=Show # of Posts
CONFIG_OPTION_show_posts=If selected, # of posts a user has made will show in their info section by each post.
SHOW_JOINED=Show Joined Date
CONFIG_OPTION_show_joined=If selected show date member joined the forum.
SHOW_LIKES=Show # of likes
CONFIG_OPTION_show_likes=If selected, and 'ikes' is turned on, show the # of likes the user has recieved. (if they are > 0)
SHOW_POINTS=Show users total points
CONFIG_OPTION_show_points=If selected show users total points.

So now you should have this in config:



You will need to create OCF_MEMBER_BOX_CUSTOM_FIELD2.tpl.  If you have not done the mod above, you will find the required code for this template above.

In OCF_TOPIC_POST.tpl you need to add the start line for SHOW_STUFF.  (you won't have the SHOW_CPF unless you did the mod at the top of this document)

Code

<div class="ocf_topic_poster_more">
             
            {POST_AVATAR}
            {+START,IF_NON_EMPTY,{RANK_IMAGES}}<div class="ocf_topic_poster_rank_images">{RANK_IMAGES}</div>{+END}
                                {+START,IF_NON_EMPTY,{POSTER_TITLE}}<div class="ocf_topic_poster_title">{POSTER_TITLE*}</div>{+END}
            {+START,IF_NON_EMPTY,{SHOW_STUFF}}<div class="ocf_topic_poster_title">{SHOW_STUFF}</div>{+END}
            {+START,IF_NON_EMPTY,{SHOW_CPF}}<div class="ocf_topic_poster_title">{SHOW_CPF}</div>{+END}
</div>

forum/pages/modules_custom/topicview.php add the following code above the  '// Poster Details' section of code:

Code (php)

                                // add posts,joined,group,likes to user info part of post.
                                $show_stuff=new ocp_tempcode();
                               
                                if (!is_guest($_postdetails['poster'])) {
                               
                                  if (get_option('show_posts')) {
                                     $show_stuff->attach(do_template('OCF_MEMBER_BOX_CUSTOM_FIELD2',array('_GUID'=>'10b72cd1ec240c315e56bc8a0f3a92b4','NAME'=>'Posts','VALUE'=>integer_format($_postdetails['poster_posts']))));
                                  }
                               
                                  if (get_option('show_joined')) {
                                    // $_postdetails['poster_join_date_string'],
                                    //date('M y', strtotime($_postdetails['poster_join_date_string']));
                                    $show_stuff->attach(do_template('OCF_MEMBER_BOX_CUSTOM_FIELD2',array('_GUID'=>'10b72cd1ec240c315e56bc8a0f3a92b4','NAME'=>'Joined','VALUE'=>date('M y', strtotime($_postdetails['poster_join_date_string'])))));
                                  }
                               
                                   if ((get_option('show_likes')) && (get_option('likes'))) {
                                    //  SELECT * FROM ocp_rating as r JOIN ocp_f_posts as p ON r.rating_for_id=p.id WHERE p.p_poster=2 AND rating=10
                                    $numlikes=$GLOBALS['SITE_DB']->query('SELECT * FROM '.get_table_prefix().'rating as r JOIN '.get_table_prefix().'f_posts as p ON r.rating_for_id=p.id WHERE r.rating_for_type="post" AND p.p_poster='.$_postdetails['poster'].' AND r.rating=10');
                                    if (!(intval($numlikes)==0)) {
                                      $show_stuff->attach(do_template('OCF_MEMBER_BOX_CUSTOM_FIELD2',array('_GUID'=>'10b72cd1ec240c315e56bc8a0f3a92b4','NAME'=>'Likes','VALUE'=>$numlikes)));
                                    }
                                  }
                               
                                  if (get_option('show_points')) {
                                    if (addon_installed('points'))
                                      $show_stuff->attach(do_template('OCF_MEMBER_BOX_CUSTOM_FIELD2',array('_GUID'=>'10b72cd1ec240c315e56bc8a0f3a92b4','NAME'=>'Points','VALUE'=>integer_format(total_points($_postdetails['poster'])))));
                                  }
                                }
 

*Note:  This version of likes just reads out likes for posts, it doesn't include other types of likes received. It requires you to have 'ratings as ikes' turned on otherwise it will not show anything.

In forum/pages/modules_custom/topicview, in function run, search down for:

Code (php)

$rendered_post=do_template('OCF_TOPIC_POST'
 

There are a bunch of things passed to the template there, at the end of the list, add on:

Code (php)

'SHOW_STUFF'=>$show_stuff,
 

Also,  in  sources_custom/ocf_posts2.php, at the bottom of the list of variables passed in do_template, you need to add

Code (php)

'SHOW_STUFF'='',
 



Extra Notes:

If you use both show_cpf and show_stuff, I prefer my OCF_TOPIC_POST.tpl to read as follows so there isn't a blank line between cpf's and the 'stuff' fields:

Code

<div class="ocf_topic_poster_more">
             {+START,IF_NON_EMPTY,{POSTER_TITLE}}<div class="ocf_topic_poster_title">{POSTER_TITLE*}</div>{+END}
            {POST_AVATAR}
            {+START,IF_NON_EMPTY,{RANK_IMAGES}}<div class="ocf_topic_poster_rank_images">{RANK_IMAGES}</div>{+END}
            <div class="ocf_topic_poster_title">
              {SHOW_STUFF}
              {SHOW_CPF}
            </div>
         </div>

In order to change order of display:  For CPF's, you need to go into the Member editor and reorder the fields you selected for 'show in post'.   For the latter mod, you need to just simply edit the order of the 'if' statements in topicview.php that we added in for that part of the mod.

There are no pages beneath this page

There are no posts yet

CEDI change-log Post