Hard Coding an extra URL in the Profile Fields

Articles for the tutorials page consisting of phpBB3 development tutorials.
Comments are welcome.
Forum rules
You can reply in this forum, but need to be an approved developer to post a new topic.

Hard Coding an extra URL in the Profile Fields

Postby topdown on Mon Apr 20, 2009 12:40 am

Note: I will be making a mod for this soon, to reduce edits!


OK, here we go, there are a lot of edits and a few things not included like adding the image.
Here is the hard coded way.

First thing you need to do is Back Up Everything database and files you will be editing. This is a must.

Files you will be editing include
  • includes/ucp/ucp_profile.php
  • styles/prosilver/template/ucp_profile_profile_info.html
  • styles/prosilver/template/memberlist_view.html
  • styles/prosilver/template/viewtopic_body.html
  • viewtopic.php
  • memberlist.php

Spoiler:
OPEN includes/ucp/ucp_profile.php
FIND
Code: Select all
               'website'      => request_var('website', $user->data['user_website']),


On a new line AFTER ADD
Code: Select all
//--------------------------------------------------------------------------------------------------//               
               'extra_link'   => request_var('extra_link', $user->data['user_link']),
//--------------------------------------------------------------------------------------------------//


FIND
Code: Select all
array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),


On a new line AFTER ADD
Code: Select all
//--------------------------------------------------------------------------------------------------//
                  'extra_link'   => array(   
                     array('string', true, 12, 255),
                     array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
//--------------------------------------------------------------------------------------------------//


FIND
Code: Select all
                     'user_website'   => $data['website'],


On a new line AFTER ADD
Code: Select all
//-----------------------------------------------------------------------------------------------//
                     'user_link'      => $data['extra_link'],
//-----------------------------------------------------------------------------------------------//


FIND
Code: Select all
               'WEBSITE'   => $data['website'],


On a new line AFTER ADD
Code: Select all
//-----------------------------------------------------------------------------------------------//
               'EXTRA_LINK'=> $data['extra_link'],
//----------------------------------------------------------------------------------------------//

SAVE FILE

OPEN styles/prosilver/template/ucp_profile_profile_info.html
FIND
Code: Select all
   <dl>
      <dt><label for="website">{L_WEBSITE}:</label></dt>
      <dd><input type="text" name="website" id="website" maxlength="255" value="{WEBSITE}" class="inputbox" /></dd>
   </dl>


On a new line AFTER ADD
Code: Select all
   <dl>
      <dt><label for="extra_link">Extra Link:</label></dt>
      <dd><input type="text" name="extra_link" id="extra_link" maxlength="255" value="{EXTRA_LINK}" class="inputbox" /></dd>
   </dl>

Note: In that last code you can see I didn't make a language var, you should.
SAVE FILE

OPEN styles/prosilver/template/memberlist_view.html
FIND
Code: Select all
<!-- IF U_WWW --><dt>{L_WEBSITE}:</dt> <dd><a href="{U_WWW}" title="{L_VISIT_WEBSITE}: {U_WWW}">{U_WWW}</a></dd><!-- ENDIF -->


On a new line AFTER ADD
Code: Select all
      <!-- IF U_USER_LINK --><dt>{L_WEBSITE}:</dt> <dd><a href="{U_USER_LINK}" title="{L_VISIT_WEBSITE}: {U_USER_LINK}">{U_USER_LINK}</a></dd><!-- ENDIF -->

Note: This is using the language var L_WEBSITE, you should make a new one in the language file for this link.

SAVE FILE

OPEN styles/prosilver/template/viewtopic_body.html
FIND
Code: Select all
<!-- IF postrow.U_WWW --><li class="web-icon"><a href="{postrow.U_WWW}" title="{L_VISIT_WEBSITE}: {postrow.U_WWW}"><span>{L_WEBSITE}</span></a></li><!-- ENDIF -->


On a new line AFTER ADD
Code: Select all
               <!-- IF postrow.U_USER_LINK --><li class="web-icon"><a href="{postrow.U_USER_LINK}" title="{L_VISIT_WEBSITE}: {postrow.U_USER_LINK}"><span>USER LINK</span></a></li><!-- ENDIF -->

AGAIN Note: This is using the website language vars, you should change them. It is also using the website icon class="web-icon"

SAVE FILE

OPEN viewtopic.php
FIND
Code: Select all
   'WWW_IMG'          => $user->img('icon_contact_www', 'VISIT_WEBSITE'),


On a new line AFTER ADD
Code: Select all
//--------------------------------------------------------------------------------------
   'USER_LINK_IMG'    => $user->img('icon_contact_www', 'VISIT_WEBSITE'),
//--------------------------------------------------------------------------------------


FIND
Code: Select all
'www'            => '',


On a new line AFTER ADD
Code: Select all
//-----------------------------------------------------
            'user_link'         => '',
//-----------------------------------------------------


FIND
Code: Select all
            'www'         => $row['user_website'],


On a new line AFTER ADD
Code: Select all
//---------------------------------------------------------------            
            'user_link'      => $row['user_link'],
//---------------------------------------------------------------


FIND
Code: Select all
      'U_WWW'         => $user_cache[$poster_id]['www'],


On a new line AFTER ADD
Code: Select all
//---------------------------------------------------------------
      'U_USER_LINK'   => $user_cache[$poster_id]['user_link'],
//---------------------------------------------------------------


SAVE FILE

OPEN memberlist.php
FIND
Code: Select all
         'WWW_IMG'      => $user->img('icon_contact_www', $user->lang['WWW']),


On a new line AFTER ADD
Code: Select all
//------------------------------------------------------------------------------------         
         'USER_LINK_IMG'   => $user->img('icon_contact_www', 'EXTRA_LINK'),
//------------------------------------------------------------------------------------   


FIND
Code: Select all
      'U_EMAIL'      => $email,
      'U_WWW'         => (!empty($data['user_website'])) ? $data['user_website'] : '',


On a new line AFTER ADD
Code: Select all
//------------------------------------------------------------------------------------------------      
      'U_USER_LINK'   => (!empty($data['user_link'])) ? $data['user_link'] : '',
//------------------------------------------------------------------------------------------------


SAVE FILE

Now you will need some SQL added to your database
Open up phpMyAdmin and go to your database, click on the SQL button and run
Code: Select all
ALTER TABLE `phpbb_users` ADD `user_link` varchar(200) collate utf8_bin NOT NULL default ''


There are still some obvious changes to be made like the image, language vars, and naming, but this should get you going.

To add it to the admin email for admin register approval


Files to edit
  • includes/ucp/ucp_register.php
  • styles/your style/template/ucp_register.html
  • language/en/email/admin_activate.txt

NOTE: You'll notice I added an @mod in the break lines, this does nothing, I just added it for a search feature so I can find all code edits easilly in the files for future use ;)

Spoiler:
OPEN includes/ucp/ucp_register.php
FIND
Code: Select all
               'email'            => strtolower(request_var('email', '')),


On a new line AFTER ADD
Code: Select all
//-- @mod ------------------------------------------------------------------------------------------------//               
               'extra_link'   => request_var('extra_link', $user->data['user_link']),
//--------------------------------------------------------------------------------------------------//


FIND
Code: Select all
         'email'            => strtolower(request_var('email', '')),


On a new line AFTER ADD
Code: Select all
//-- @mod ------------------------------------------------------------------------------------------------//               
         'extra_link'      => request_var('extra_link', $user->data['user_link']),
//--------------------------------------------------------------------------------------------------//


FIND
Code: Select all
            'email'            => array(
               array('string', false, 6, 60),
               array('email')),


On a new line AFTER ADD
Code: Select all
//-- @mod ------------------------------------------------------------------------------------------------//
            'extra_link'   => array(   
               array('string', true, 12, 255),
               array('match', true, '#^http[s]?://(.*?\.)*?[a-z0-9\-]+\.[a-z]{2,4}#i')),
//--------------------------------------------------------------------------------------------------//


FIND
Code: Select all
               'user_email'         => $data['email'],


On a new line AFTER ADD
Code: Select all
//-- @mod ---------------------------------------------------------------------------------------------//
               'user_link'            => $data['extra_link'],
//-----------------------------------------------------------------------------------------------//


FIND This part is untested :glare: It should include the link to the admins in the activation email.
Code: Select all
                        'USERNAME'         => htmlspecialchars_decode($data['username']),


On a new line AFTER ADD This part is untested :glare: It should include the link to the admins in the activation email.
Code: Select all
//-- @mod ---------------------------------------------------------------------------------------------//
                        'USER_LINK'         => htmlspecialchars_decode($data['extra_link']),
                        //-----------------------------------------------------------------------------------------------//
                        


FIND
Code: Select all
         'EMAIL'            => $data['email'],


On a new line AFTER ADD
Code: Select all
//-- @mod ---------------------------------------------------------------------------------------------//
         'EXTRA_LINK'      => $data['extra_link'],
//----------------------------------------------------------------------------------------------//
         


SAVE FILE

OPEN styles/your style/template/ucp_register.html
FIND
Code: Select all
   <dl>
      <dt><label for="password_confirm">{L_CONFIRM_PASSWORD}:</label></dt>
      <dd><input type="password" tabindex="5" name="password_confirm" id="password_confirm" size="25" value="{PASSWORD_CONFIRM}" class="inputbox autowidth" title="{L_CONFIRM_PASSWORD}" /></dd>
   </dl>


On a new line AFTER ADD
Code: Select all
   <hr />
   <dl>
      <dt><label for="extra_link">Extra Link:</label></dt>
      <dd><input type="text" name="extra_link" id="extra_link" size="25" maxlength="255" value="{EXTRA_LINK}" class="inputbox autowidth"  /></dd>
   </dl>


SAVE FILE

OPEN language/en/email/admin_activate.txt (This part is untested)
FIND
Code: Select all
{U_USER_DETAILS}


On a new line AFTER ADD
Code: Select all
The user's included site link is {USER_LINK}


SAVE FILE

upload, and refresh your templates via the ACP/ styles tab and purge your cache from the Admin main page
User avatar
topdown
Site Admin
 
Posts: 143
Joined: Sun Jul 27, 2008 6:55 pm
Location: In the CODE ©
Sites Developed: 22
phpBB3 Styles: 16
phpBB3 Knowledge: 9
phpBB3 Mods: 11

Return to phpBB3 Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron