views:

1322

answers:

2

Basically I'm a bit stuck,

I've been following the quick start on Zend site, and wish to make a dynamic navigation to the framework, I've got layout.phtml with $this->render('navigation.phtml); this has static links, but I wish to make them pull from a database table could someone in plain english not geekcaneeze explain the correct way of doing this, IE page by page with simple step by step guide on what each page is doing, as I'm not a PHP FREAK or Zend Framework master but a web designer who wants to progress in to the world of framework development, I understand the concept the vaules of it's use.

I'm sure it will cure a lot of headaches for a lot of newbies to this. in other words after reading zend frame work referance I'm still none the wiser what they are going on about.

I've got it all working though Xampp and the file structure represent the same as

application/ 
config/
controllers/
layout/script/
models/
views/script/index/
views/script/error/
library/ 
public/

regards

Mal

+1  A: 

Pull them out in a controller, pass them along (eg. as an array) to the view:

$this->view->yourListOfLinks = getListOfLinksFromDB();

In the view (the .phtml) example output them using foreach:

foreach($this->yourListOfLinks as $link) {
   echo "<a href=\"$link\">$link</a>";
  }
vartec
+1  A: 

Assuming you set up a class for your your database table (ZF - Create a Model and Database Table), you should be able to do something like this in your navigation.phtml file:

<?php
$table = new Links_Table();
$links = $table->fetchAll();
?>

<? foreach ($links as $link) { ?>
   <a href="<?= $link->url ?>"><?= $link->title ?></a>
<? ?>

If you're creating internal site links then you could also set up some router rewrite rules (ZF - The Standard Router).

Jack Sleight