Programming XHTML Templates

It has been some time since I did some hard web design, so I have a question for you. I am sure there is an xhtml function that allows you to create a template and include this template on other xhtml pages. I am trying to create a “main links” template that allows any page to link to the main pages of the site. I decided that the template would be better to use, as this would make it easy to edit these links. If I just needed to encode them on all pages, that would be a nightmare if I had to change something.

Btw, this site runs only in xhtml, css and javascript. I could use something more muddy like jsf, but I just didn't want to.

If anyone has any ideas on this or suggestions on a better way to do this, it would be great.

Thanks Robbie

+3
source share
4 answers

You probably want to do something with include, which is not part of XHTML, but rather server-side technology such as PHP or ASP.

See W3School articles on PHP include () and require () and ASP including files .

As far as I know, in XHTML, CSS and / or JavaScript there is nothing that you would like.

+2
source

You can extend DTD with entities (as described in http://xml.silmaril.ie/authors/includes/ ), but you will find browser support as poor as for XInclude .

- , , XHTML, -, XHTML ( , ).

http://allmyfaqs.net/faq.pl?Include_one_file_in_another - .

+2

- asp.net?

AJAX Serverside . XHTML . . - , .

php :

page.php

<?php ob_start(); ?>
    your page
<?php 
    $content = ob_get_contents();
    ob_end_clean();
    $title="pagetitle";
    require("template.php");
?>

template.php

Use <?php echo $title; ?> where you want your title
Use <?php echo $content; ?> where you want your content
+1

If you really want to stay away from server-side technologies that can offer the required features, you can find an IDE / editor that supports templates or includes something like that. I have no experience with this, so I cannot recommend specific software, but I know that there are IDEs / editors that offer the functionality you are looking for.

0
source

Source: https://habr.com/ru/post/1713256/


All Articles