douxuan0698 2009-02-06 17:00
浏览 29

如何在Zend 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

  • 写回答

2条回答 默认 最新

  • duanlei5339 2009-02-06 17:59
    关注

    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>";
      }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据