2010-10-21 15 views
0

我在我的網站上安裝了Joomla的TPLancer組件,我正在嘗試向自由譯者和買方的個人檔案頁面添加更多信息。我不是PHP或mySQL的天才,但可以通過平常的方式虛張聲勢。 當前顯示在配置文件頁面上的信息只是從數據庫中提取的數據。我在數據庫中添加了一個新的「網站」行,並在數據庫中輸入了一些數據,但似乎無法顯示。我認爲它會像echo $ row-> website一樣;因爲echo $ row-> categories;工程和echo $ row-> company;他們都在同一張桌子上。
有什麼事情發生,顯然是高於我的頭。下面我從tplancer.php文件粘貼了一段代碼,其中包含我試圖定位的功能。
下面是來自tplancer.html.php文件的一些代碼,它顯示頁面上的實際HTML。 我希望有人能幫忙,我希望我聽起來不會太笨!乾杯Joomla TPlancer組件添加新字段並顯示

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(); 
if(!$id) 
{ 
    echo "Freelancer not found!"; 
    return; 
} 
$query = "select username FROM #__users where id =".$lancer_id; 
$db->setQuery($query); 
$username = $db->loadResult(); 
$row =& JTable::getInstance('lancer','Table'); 
$row->load($id); 
$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(); 

HTML_front_glance::showLancerInfo($option,$row,$projects,$bids,$username); 

}

功能showLancerInfo($選項,$行,$項目,$出價$用戶名) { 全球$主機,$選項; $ user = & JFactory :: getUser();

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

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

    <?php 
       $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" />'; 
       } 
       else 
       { 
        $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> 

回答

1

嘗試查找名爲「表」的組件中的文件夾。找到正確的文件,它應該被稱爲「lancer」,在那裏爲你想要的表定義表變量並添加你希望顯示的新變量 - 例如

... 
var $website = null; 
... 

然後你就可以像你說的那樣使用$ row-> website。

你正在尋找的模型功能的線索是這一行:

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

我希望可以解決您的問題!祝你好運!

+0

謝謝馬丁。雖然沒有任何'Lancer'文件。下面的代碼是從tplancer.php文件開始的 - 這能否讓我朝着正確的方向發展? jimport('joomla.application.helper'); require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_tplancer'.DS.'helper.php'); require_once(JApplicationHelper :: getPath('html')); JTable :: addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_tplancer'.DS.'tables'); – snails07 2010-10-21 23:44:13

+0

對不起,馬丁,你是真的。 'lancer'文件位於'tables'文件夾中,但隱藏在組件admin文件夾中。我沒有想到要檢查那個。感謝您的幫助,您是絕對的救星! – snails07 2010-10-22 00:25:28

相關問題