php – Joomla TPlancer component adding new field and displaying – Education Career Blog

I have the TPLancer component for Joomla installed on my site and I am trying to add some more information to the profile page of both the Freelancer and the Buyer. I am no genius with PHP or mySQL but can kind of bluff my way thru usually.
The information currently displayed on the profile pages is just data pulled from the database. I have added a new ‘website’ row in the database and have entered some data into the database but I can’t seem to get it to display. I thought it would just be something like echo $row->website; because echo $row->categories; works and so does echo $row->company; and they are all in the same table.
There is something happening that is obviously way above my head. Below I have pasted a section of the code from the tplancer.php file which contains the function for what I am trying to target.
Below that is some code from the tplancer.html.php file which displays the actual HTML on the page.
I hope someone can help and I hope I don’t sound too dumb! Cheers

function showLancerInfo($option)
global $mainframe;
$user =& JFactory::getUser();
$db =& JFactory::getDBO();
$lancer_id = JRequest::getVar('id', 0, 'get', 'int');

$is_lancer = isLancer($user->id);
$is_buyer = isBuyer($user->id);
$query = "select id FROM #__glance_lancer where userid =".$lancer_id;   
$db->setQuery( $query );
$id = $db->loadResult();
    echo "Freelancer not found!";
$query = "select username FROM #__users where id =".$lancer_id; 
$db->setQuery( $query );
$username = $db->loadResult();
$row =& JTable::getInstance('lancer','Table');  
$query = "select * FROM #__glance_projects where chosen =".$lancer_id." ORDER BY id desc LIMIT 10";
$db->setQuery( $query );
$projects = $db->loadObjectList();
$query = "select * FROM #__glance_bids where userid=".$lancer_id." order by id desc LIMIT 10 ";
$db->setQuery( $query );
$bids = $db->loadObjectList();



function showLancerInfo($option,$row,$projects,$bids,$username)
global $mainframe, $option;
$user =& JFactory::getUser();

    $lancer_info = getUserInfo($row->userid);

    <!-- ///////////////////////  FREELANCER PROFILE PAGE ///////////////////////   -->

                $img = JPATH_SITE.DS.'images'.DS.'glance'.DS.$row->userid.'.jpg';
                if(file_exists($img)) {
                    $img = JURI::base().'images/glance/'.$row->userid.'.jpg';
                    echo '<img class="profile_logo" src="'.$img.'" alt="Logo" />';
                    $img = JURI::base().'components/com_glance/images/noimage.jpg';
                    echo '<img class="profile_logo" src="'.$img.'" alt="Logo"/>';

    <div class="profile_info">
        <h1><?php echo $lancer_info'username' ?><?php if($row->special=='y')  {?>
                <img src="components/com_glance/images/featured.png" alt="Featured" class="feat_lancer" />
                <?php } ?></h1>
        <h3><?php echo $row->company ;?></h3>
        <p><?php echo $row->categories ; ?></p>
        <p>Website: <?php echo $row->website; ?></p>
        <p>Hourly Rate US $<?php echo $row->rate; ?></p></code>


Trying look for a folder in the component called “tables”. Find the correct file, it should be called “lancer”, in there that defines the table variables for the table you want and add the new variables you wish to display – e.g.

var $website = null;

Then you will be able to use, as you said, $row->website.

The clue you are looking for in the model function is this line:

$row =& JTable::getInstance('lancer','Table');

I hope that solves your problem! Good luck!

Leave a Comment