一种通过更改一个文件来编辑内容的方法?

发布于 2024-08-28 11:46:06 字数 2162 浏览 4 评论 0原文

我的网站左侧有一个联系 CSS 选项卡,我有超过 30 个页面,我不想在数据更改后手动更改所有这些页面。有谁知道解决方案,这样我只需更改 1 个文件即可编辑所有页面?

也许在 JavaScript 中?

下面的代码用于“

<div class="slide-out-div">
        <a class="handle" href="http://link-for-non-js-users">Content</a>
      <h3>Onze contact gegevens</h3>
        <p>Adres: van Ostadestraat 55<br />
          Postcode: 8932 JZ<br />
        Plaats: Leeuwarden<br />
        Tel: 058 844 66 28<br />
        Mob: 0629594595
        <br />
        E-mail: <a href="mailto:[email protected]">[email protected]</a><br /><br />
        </p>
<p>Mocht u vragen hebben dan kunt u gerust bij ons terecht voor meer informatie.</p>

编辑”选项卡:

这是在我的 html 中

<!--#include virtual="contact.txt" -->
  </body>

,这是在我的 contact.txt 中,它位于我的 web 文件夹的 rot 中:

<div class="slide-out-div">
        <a class="handle" href="http://link-for-non-js-users">Content</a>
      <h3>Onze contact gegevens</h3>
        <p>Adres: van Ostadestraat 55<br />
          Postcode: 8932 JZ<br />
        Plaats: Leeuwarden<br />
        Tel: 058 844 66 28<br />
        Mob: 0629594595
        <br />
        E-mail: <a href="mailto:[email protected]">[email protected]</a><br /><br />
        </p>
<p>Mocht u vragen hebben dan kunt u gerust bij ons terecht voor meer informatie.</p>

I have a contact css tab on my left side on my website, I have more then 30 pages and I don't wantto manually alter all those pages later when data had changed. Does anyone knows a sollution so I only have to alter 1 file to have all pages edited?

Perhaps in javascript?

The code below is for the tab

<div class="slide-out-div">
        <a class="handle" href="http://link-for-non-js-users">Content</a>
      <h3>Onze contact gegevens</h3>
        <p>Adres: van Ostadestraat 55<br />
          Postcode: 8932 JZ<br />
        Plaats: Leeuwarden<br />
        Tel: 058 844 66 28<br />
        Mob: 0629594595
        <br />
        E-mail: <a href="mailto:[email protected]">[email protected]</a><br /><br />
        </p>
<p>Mocht u vragen hebben dan kunt u gerust bij ons terecht voor meer informatie.</p>

Edit:

This is in my html

<!--#include virtual="contact.txt" -->
  </body>

and this is in my contact.txt which is located in the rot of my webfolder:

<div class="slide-out-div">
        <a class="handle" href="http://link-for-non-js-users">Content</a>
      <h3>Onze contact gegevens</h3>
        <p>Adres: van Ostadestraat 55<br />
          Postcode: 8932 JZ<br />
        Plaats: Leeuwarden<br />
        Tel: 058 844 66 28<br />
        Mob: 0629594595
        <br />
        E-mail: <a href="mailto:[email protected]">[email protected]</a><br /><br />
        </p>
<p>Mocht u vragen hebben dan kunt u gerust bij ons terecht voor meer informatie.</p>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

焚却相思 2024-09-04 11:46:06

您可能需要使用服务器端包含 (SSI)。

您可以将代码片段放入一个单独的文件中,例如 contact.txt,然后您只需在所有 30 个页面中引用它即可:

<!--#include virtual="contact.txt" -->

所有流行的 Web 服务器都支持 SSI,包括Apache、IIS 和 lighttpd。

You may want to use Server Side Includes (SSI).

You would place your code snippet into a separate file, such as contact.txt, and then you would simply reference it in all your 30 pages by using:

<!--#include virtual="contact.txt" -->

SSI is supported by all the popular web servers, including Apache, IIS and lighttpd.

你的心境我的脸 2024-09-04 11:46:06

创建一个包含相关 HTML/文本的文本文件,并将其放入 HTML 中您希望其显示的位置。

<!--#include virtual="path to file/include-file.txt" -->

希望有所帮助:)

更新:

经过长时间的讨论,将您的页面重命名为 .php 而不是 .html,将您的联系人重命名为 .php 而不是 .txt,并使用它来包含您的文件:

<?php include('contact.php'); ?>

如果您的页面位于不同的目录中,请使用:

<?php include($DOCUMENT_ROOT . "/path-to-files/contact.php"); ?>

这将强制页面查看站点的根目录。

Create a text file with the relevant HTML/text and put this into your HTML where you want it to appear.

<!--#include virtual="path to file/include-file.txt" -->

Hope that helps :)

UPDATE:

After the lengthy discussion, rename your pages to .php instead of .html and your contact to .php instead of .txt and use this to include your file:

<?php include('contact.php'); ?>

If your pages are in different directories, use:

<?php include($DOCUMENT_ROOT . "/path-to-files/contact.php"); ?>

This will force the page to look at the root directory of your site.

燕归巢 2024-09-04 11:46:06

正如建议的,您可以使用 Apache 的 SSI。这取决于所使用的特定网络服务器和模块。

为了达到这个结果,你可以做两件事:

使用某种支持它的模板语言,并在上传到你的网络服务器之前“编译它”。使用 ruby​​ 的 ERB 就是一个例子。

另一种方法是使用服务器端编程语言(我推荐 PHP,因为它简单、易于部署并且有大量文档)在服务器上为您执行此操作。

下面是一个使用 PHP 的简单示例: http://www.albinoblacksheep.com/tutorial/include< /a>

As suggested, you can user Apache's SSI. That depends on that specific webserver and module being used.

To achieve that result you could either do two things:

Use some kind of templating language that supports it, and "compile it" before uploading to your webserver. Using ruby's ERB is one example.

Other is to use a server-side programming language (I'd recommend PHP as it's simple, easy to deploy and lot's of documentation around) to do that for you on the server.

Here is a simple example of that using PHP: http://www.albinoblacksheep.com/tutorial/include

我的鱼塘能养鲲 2024-09-04 11:46:06

我接受丹尼尔和凯尔的解决方案(并且我+1他们的答案)

如果我处于你的情况, 。我用您的联系信息制作了一个 html,然后将其与框架一起包含到其他 30 个页面中,例如

  • contact.html(仅包含联系信息)
  • page1.htm
  • pagex.htm
  • page30.htm

并在一个 pagex.htm 中放入以下代码

<body>
     Other part of page ....
     <iframe id="contact" src="../contact.htm"></iframe>
</body>

As I Accept both Daniel and Kyle solutions (and I +1 their answers)

If Iwere inyour situation. I maked a html with your contact info and then include it with a frame into 30 other pages like

  • contact.html (which includes only contact info)
  • page1.htm
  • pagex.htm
  • page30.htm

and in one pagex.htm put following code

<body>
     Other part of page ....
     <iframe id="contact" src="../contact.htm"></iframe>
</body>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文