Php – How to create dynamic links from database in Zend Framework

MySQLPHPzend-framework

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

Best Answer

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>";
  }
Related Topic