2016-07-30 76 views
0

我創建了一個頁面,我想從數據庫中顯示列表。我從這個link遵循相同的步驟,這是正常工作。但問題是,我不能從數據庫循環數據在my tpl file。在tpl文件我顯示列表使用prestashop在自定義頁面顯示數據庫中的數據

<table> 
    <tr> 
    <th>Company</th> 
    <th>Contact</th> 
    <th>Country</th> 
    </tr> 
    <tr> 
    <td>Alfreds Futterkiste</td> 
    <td>Maria Anders</td> 
    <td>Germany</td> 
    </tr> 
</table> 

請幫助我。

+0

你告訴我們,使用控制器的內容是什麼? –

+0

請打開鏈接,複製鏈接https://iftakharhasan.wordpress.com/2014/04/05/prestashop-create-a-custom-page-without-cms/。但在這個鏈接控制器沒有調用? – Coder

+0

你如何改變內容CustomPageController.php? –

回答

0

在custom-page.php之前:$ smarty-> display(_PS_THEME_DIR _。'custom-page.tpl');

地址:

$customer = CustomerCore::getCustomers(); 

$contact =array(); 

foreach ($customer as $c){ 
    $id = AddressCore::getFirstCustomerAddressId($c['id_customer']); 
    $contact[] = new AddressCore($id); 
} 

$smarty->smarty->assign(array('contacts'=>$contact)); 

在定製page.tpl插入:

<table> 
    <tr> 
    <th>Company</th> 
    <th>Contact</th> 
    <th>Country</th> 
</tr> 
{foreach $contacts as $contact} 
    <tr> 
     <td>{$contact->company}</td> 
     <td>{$contact->lastname} {$contact->firstname}</td> 
     <td>country</td> 
    </tr> 
{/foreach} 
+0

謝謝你我會嘗試一下。那麼我會通知你。 – Coder

+0

好吧,讓我知道:) –

相關問題