douyi0219 2010-08-02 15:24
浏览 53
已采纳

将元素添加到其他元素

I have been using .net for the past couple of years, and I like the way you can add controls at any point in the page from anywhere. For example, you can say Head.Controls.add(new LiteralControl("<link rel='stylesheet' type='text/css' href='styles.css' />")) even if there is already a body.

Is it possible to do this kind of thing in php? My site is set up so that we have agents, customers and artists (this is for a card manufacturing company who wants a customer application for use offline at tradeshows). The add agent form may have different styles to the add customer form. I want to therefore have each type in a different folder (for example agents, customers and artists) each with their own stylesheet. There will be one form page which takes GET parameters of type (artist, customer etc), mode (create, edit) and an optional parameter of ID (when in edit mode). I would like to be able to call $agentForm->generateForm() and $agentForm->generateStyleTag() in one go, rather than what I am currently doing which is to call $agentForm->generateForm() in the body and $agentForm->generateStyleTag when in the head (without even the start body tag being generated yet).

A good way to put this is that I have a Head tag and a Body tag. In another function called $agentForm->generateHTML() I want to say Body->addChild("bla") and Head->addChild("bla"). This makes developing a new page a lot easier since it ensures the styles are there and are correct for the section of the site the user is in.

Is it possible to achieve this, or is this one of the major differences between php and .net?

  • 写回答

4条回答 默认 最新

  • download1323 2010-08-02 15:34
    关注

    Have a look at the PRADO framework and the Yii framework. They have a hierarchical, component-based philosphy that allows nesting and composition, essentialling building a whole site from smaller, pluggable components.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探