2016-07-30 30 views
0

データベースからのリストを表示するページを作成しました。私はこれと同じ手順を踏襲していますlinkは正常に動作しています。問題は私がmy tpl fileのデータベースからデータをループできないことです。 tplファイルでは、私はプリスタッシュを使用してカスタムページにデータベースからデータを表示

<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

リンクiを開き、このリンクから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');

追加:カスタム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)); 

<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

よろしくお願いします:) –

関連する問題