简体   繁体   English

等效的Dreamweaver模板

[英]Dreamweaver Templates Equivalent

I have been using Dreamweaver to build several sites. 我一直在使用Dreamweaver构建多个站点。 In particular, I utilize its templates to manage consistent layout / design throughout each site. 特别是,我利用其模板来管理每个站点的一致布局/设计。

In a nutshell, it works like this: 简而言之,它的工作方式如下:

  1. Create a template, for example: 创建一个模板,例如:
    • <html><body><h1><!-- Marked as editable region. --></h1></body></html>
  2. Create a new page based on the template 根据模板创建一个新页面
    • <html>body><h1>Hello World!</h1></body></html>

So, if I need to change h1 to h2, I'd simply edit the template and all pages based on it will get updated automatically: simple. 因此,如果需要将h1更改为h2,则只需编辑模板,基于该模板的所有页面都将自动更新:简单。 The question is how do I do this without depending myself on a proprietary application like Dreamweaver? 问题是,如何在不依赖Dreamweaver等专有应用程序的情况下执行此操作?

I am hoping a simplest possible solution. 我希望有一个最简单的解决方案。 By simplest I mean, I hope I don't need to build a CMS or something. 简单来说,我希望我不需要构建CMS或其他东西。 :) :)

Thanks! 谢谢!

Update : Can we do this using eg PHP? 更新 :我们可以使用例如PHP做到这一点吗?

There are tones of several ways to do what you want. 有几种方法可以完成您想要的操作。

Let's start from the Apache level: 让我们从Apache级别开始:

In case your web site run under apache you can use a module called SSI. 如果您的网站在apache下运行,则可以使用称为SSI的模块。 SSI Stands for Server Side Includes. SSI代表服务器端包含。 This is the simple way if you like to create template like web sites with HTML. 如果您想使用HTML创建类似网站的模板,这是一种简单的方法。 The method allows you to split you web page into several files and then the server will compose all these into one page. 该方法允许您将网页拆分为多个文件,然后服务器会将所有这些文件组合为一个页面。 So you can have in example a header.html footer.html sitebar.html about_us.html and when you call the about_us.html the server will load also the other three files into that one. 因此,您可以在示例中使用header.html footer.html sitebar.html about_us.html,当您调用about_us.html时,服务器还将其他三个文件加载到该文件中。

Using PHP require(_once) or include(_once): 使用PHP require(_once)或include(_once):

PHP have four commands that allows the developer to load external php files into the current working file. PHP有四个命令,允许开发人员将外部php文件加载到当前的工作文件中。 So in example you can have the files header.php, footer.php about_us.php. 因此,在示例中,您可以拥有header.php,footer.php about_us.php文件。 and into about_us.php you can include the external files. 并在about_us.php中可以包含外部文件。 Consider that as an example: 考虑一个例子:

header.php header.php文件

<html>
    <head>
        <title>My page title</title>
    </head>
    <body>

footer.php footer.php

    </body>
</html>

about_us.php about_us.php

<?php
    require_once('header.php');
?>
Enter here HTML for your about us page
<?php
    require_once('footer.php');
?>

Using a template Engine: 使用模板引擎:

You can use a template engine like smarty. 您可以使用诸如smarty之类的模板引擎。 That engine requires PHP and is somehow difficult to use it. 该引擎需要PHP,并且使用起来有些困难。 This is the most famous template engine for a long time now. 这是很长一段时间以来最著名的模板引擎。

Using a programming language framework: 使用编程语言框架:

You can use a programming language framework, such us CakePHP that allows you to split your theme and create your own theme. 您可以使用诸如CakePHP这样的编程语言框架,该框架允许您拆分主题并创建自己的主题。

This list can be a really long. 此列表可能非常长。 For now I thing you are ready to go with the most famous methods for templates ;) 就目前而言,您已经准备好使用最著名的模板方法了;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM