PCP - Add fields from tables other then "users"

Support for IntegraMOD 140

Moderator: Integra Moderator

PCP - Add fields from tables other then "users"

PostAuthor: Whisky » Mon Nov 20, 2006 2:31 am

Hi,

I would like to know if it is possible to add fields to PCP that are not part of the user table?

For instance I've got a table with the professions of my guild mates in World of Warcraft and I would like to display thoses professions in the viewtopic left

I can manage to make this completely manually by adding a new query in the viewtopic.php and send the new fields received in some new zones of the viewtopic template. However since PCP has been developped for this purpose I am trying to add this fields only with PCP.

So I created a "linked table" with a join like this:
Code: Select all
LEFT JOIN WRFR_skill AS [METIERS] ON ([METIERS].char=[USERS].username AND [METIERS].type = "MÃÂÂ ©tiers" AND [METIERS].purelevel > 1)

(METIERS means Profession/skill in french)
but unfortunately I do not see the new fields that should appear with this new Join anywhere so I guess we can only "import" fields that are part of the user table 8)

Whisky
Last edited by Whisky on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
I am the Lizard King, I can do anything

Whisky
Sr Integra Member
Sr Integra Member
 
Posts: 256
Likes: 0 post
Liked in: 0 post
Joined: Thu May 18, 2006 1:28 am
Cash on hand: 0.00
Location: Brussels

Re: PCP - Add fields from tables other then "users"

PostAuthor: Teelk » Mon Nov 20, 2006 3:47 pm

Hey Whiskey,

Try something like this...

In profilcp/def/def_userfields.php add this to the generic informations.
Code: Select all
            'user_metiers' => array(                 'lang_key'     => 'Metiers',                 'class'        => 'generic',                 'type'         => 'VARCHAR',                 'dsp_func'     => 'pcp_output_metiers',             ),  
Then open profilcp/def/def_usermaps.php.
FIND
Code: Select all
                    ),             ),         'PHPBB.viewtopic.left.ignore' => array(  
BEFORE ADD
Code: Select all
                        'user_metiers' => array(                                 'txt'          => true,                                 'style'        => '<div>%s</div>',                             ),  


In def_userfields.php we have user_metiers calling to a display functions. I don't know the specifics of what you need, so I'll try to do something that can help you write one. Here's a basic outline of a display function that should be placed in profilcp/def/def_userfuncs_custom.php.

Code: Select all
//-----------------------------------//// metiers output function////-----------------------------------function pcp_output_metiers($field_name, $view_userdata, $map_name=''){     global $board_config, $phpbb_root_path, $phpEx, $lang, $images, $userdata, $view_userdata;     global $values_list, $tables_linked, $classes_fields, $user_maps, $user_fields; // don't forget to add globals for any vars not defined in this function.       $txt = '';     $img = '';       $sql = 'SELECT WRFR_skill FROM ' . WOW_TABLE .         WHERE wow_user_id = $view_userdata['user_id']; // The SQL query, I just made this up to guide you.     if ( !$result = $db->sql_query($sql) )     {         message_die(GENERAL_ERROR, 'Could not get WOW skills information', '', __LINE__, __FILE__, $sql);     }     $wow_row = $db->sql_fetchrow($result);         // txt - this is the text that's displayed     $txt = '<span>' . $wow_row['WRFR_skill'] . '</span>';       $temp_url = append_sid("./wow_char.$phpEx?mode=viewchar&" . POST_USERS_URL . '=' . $view_userdata['user_id']); // If you want to add a URL to an image or to the text above... I just made this up...       // img - you can also have an image if you like, but you'll need to add it to the usermaps field as 'img'          => true, to get it to display.     $img = '<a><img></a>';       // result     $res = pcp_output_format($field_name, $txt, $img, $map_name);     return $res; }
Last edited by Teelk on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
User avatar
Teelk
Dev Team
Dev Team
 
Posts: 1309
Likes: 0 post
Liked in: 0 post
Joined: Tue Mar 14, 2006 5:25 pm
Cash on hand: 0.00
Location: Canada

Re: PCP - Add fields from tables other then "users"

PostAuthor: Whisky » Tue Nov 21, 2006 2:14 am

Thanks a lot m8 I am gonna try this ASAP :)

Cheers
Last edited by Whisky on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
I am the Lizard King, I can do anything

Whisky
Sr Integra Member
Sr Integra Member
 
Posts: 256
Likes: 0 post
Liked in: 0 post
Joined: Thu May 18, 2006 1:28 am
Cash on hand: 0.00
Location: Brussels

Re: PCP - Add fields from tables other then "users"

PostAuthor: Teelk » Tue Nov 21, 2006 2:46 am

The main purpose of PCP is to be able to add and remove fields easily that already exist using the graphical interface, customizing your board. This is great from a development point of view, as a lot of fields can be added without worrying too much about what users want and don't want, because they can add or remove them quite easily after installing their board.

Adding new fields can be a little more difficult, and there are several ways to go about it. Fields in the users table can be added easily enough.

I agree though, and wish it were easier to add things outside of the users table.
Last edited by Teelk on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
User avatar
Teelk
Dev Team
Dev Team
 
Posts: 1309
Likes: 0 post
Liked in: 0 post
Joined: Tue Mar 14, 2006 5:25 pm
Cash on hand: 0.00
Location: Canada

Re: PCP - Add fields from tables other then "users"

PostAuthor: Whisky » Tue Nov 21, 2006 6:36 am

Again, thank you very much... its working like a charm :mrgreen:
Last edited by Whisky on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
I am the Lizard King, I can do anything

Whisky
Sr Integra Member
Sr Integra Member
 
Posts: 256
Likes: 0 post
Liked in: 0 post
Joined: Thu May 18, 2006 1:28 am
Cash on hand: 0.00
Location: Brussels

Re: PCP - Add fields from tables other then "users"

PostAuthor: Whisky » Wed Nov 22, 2006 7:48 am

I've got another question related to PCP and cannot find an answer on the forum:

Some "official phpbb" fields of the viewtopic left card are hidden to guests (for instance Age, Number of posts, location), I would like to make appear all the fields for everybody otherwhise I have some annoying display problems.

Where is this done? (I swear I searched before asking :)
(Be patient it's sometimes very slow coz it's a TEST site with a completly defective DB)

Thanks
Last edited by Whisky on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
I am the Lizard King, I can do anything

Whisky
Sr Integra Member
Sr Integra Member
 
Posts: 256
Likes: 0 post
Liked in: 0 post
Joined: Thu May 18, 2006 1:28 am
Cash on hand: 0.00
Location: Brussels

Re: PCP - Add fields from tables other then "users"

PostAuthor: Teelk » Wed Nov 22, 2006 10:12 pm

Go to ACP>PCP>PCP Wizard, click Alter Page Display. From the drop down menu select phpBB>>View Topic>>Left and click submit.

Find the fields you want to be visible to guests and in the display when drop down menu select display always.
Last edited by Teelk on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
User avatar
Teelk
Dev Team
Dev Team
 
Posts: 1309
Likes: 0 post
Liked in: 0 post
Joined: Tue Mar 14, 2006 5:25 pm
Cash on hand: 0.00
Location: Canada

Re: PCP - Add fields from tables other then "users"

PostAuthor: Whisky » Thu Nov 23, 2006 1:52 am

It worked great, thanks again <img>
Last edited by Whisky on Wed Dec 31, 1969 4:00 pm, edited 1 time in total.
I am the Lizard King, I can do anything

Whisky
Sr Integra Member
Sr Integra Member
 
Posts: 256
Likes: 0 post
Liked in: 0 post
Joined: Thu May 18, 2006 1:28 am
Cash on hand: 0.00
Location: Brussels


Return to IntegraMOD 140

Who is online

Registered users: Bing [Bot], Google [Bot], Majestic-12 [Bot]