开发者

best practice to integrate web parters html header and footer

开发者 https://www.devze.com 2023-01-08 04:47 出处:网络
Let\'s say you want to work with a lot of parters and customize your website for them. The constraints are

Let's say you want to work with a lot of parters and customize your website for them. The constraints are

  1. they want to have their own
    • HEAD-information (javascript, css, sometimes title & meta)
    • body header
    • body columns (right or left)
    • body footer
  2. they want to be able to modify header/开发者_运维知识库footer often
  3. iframe is not an option

what would be a good way to do that ?

Thank you


Have you considered a template engine? The MVC (model-view-controller) pattern, sometimes also called view-model-template, is quite popular along web projects. Assuming a good template engine (you haven't mentioned a technology, so i can't recommend a specific one), it will be possible to inherit from templates and override or extend those blocks you want to change. So it will be easy to modify any block (e.g. header/footer/content/sidebar/...) you want. The layout is completely separated from the controller behind.

Those template engines I know all have a configurable load-path for their templates. So one good solution might be to create separate folders for each individual layout and add one of them (depending on the request) in front of the default load path. If there is a template in the individual-layout folder it will be used (which might then extend the default one), otherwise the default template will be used. But the concept might differ, depending on the template engine you use.

If you really want to only add headers and footers, something likes Apache's mod_layout might suit you, but it seems not to be very popular anymore and you might exceed its limits soon. Unique web designs has become more important over the last years, and just changing the header is often not enough anymore. So, the best-practice is in my opinion clearly a good template engine.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号