dru5089 2012-03-05 20:19 采纳率: 0%
浏览 27
已采纳

如何处理Yii下的子页面概念?

This is a very newbie question so bear with me. I'm starting to use Yii as my first PHP framework and so far so good, the project on wich I'm learning is a simple informative webpage, but how am I supposed to handle the subpage concept under Yii? This is what I'm trying to achieve:

  • Home
  • Products
    • Product 1
    • Product 2
  • Contact

I have a controller for Home, Products and Contact, now I know that Yii doesn't work with subcontrollers, then how do I create a Product 1 and 2 subpages? Just a different view for each one? Through Gii? Many thanks.

  • 写回答

1条回答 默认 最新

  • dongyouzhi7218 2012-03-05 20:35
    关注

    You could do one of two things

    You could have a generic product page that accepts a parameter to distinguish between different products (common approach). For example, www.mysite.com/products?id=1 would show Product1's page whereas www.mysite.com/products?id=2 would show Product2's page (and if there is no id parameter in the query string, then you could just show your Product page)


    And you could also have separate methods for each page. So you would have

    actionProduct
    actionProduct1
    actionProduct2
    

    methods in your Product controller and then you could reach your pages as

    www.mysite.com/product
    
    www.mysite.com/product1
    
    www.mysite.com/product2
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?