[Answer]-Creating a single menu across multiple web pages โ€“ without PHP

1๐Ÿ‘

I think what you want to do is extend a template.

Make a file called something like base.html. In this file, put your menu, or anything else you want across all of your pages.

Then, include something that looks like this.

{% block content %} {% endblock %}

In the rest of your templates (for actually serving the content), you have to include the line {% extends "base.html" %} as the very fist line.

Then surround your content with:

{% block content %}
    Your content Here
{% endblock %}

For more information see https://docs.djangoproject.com/en/dev/ref/templates/builtins/#extends and https://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance

0๐Ÿ‘

For a simple solution use an <iframe> with a single menu.html file as source.

<iframe src="menu.html"></iframe>

Frames might not be the most efficient solution but it sure is the simplest.

This way you can get the same page in every page.

Tip: format it border less for a stealth integration!

๐Ÿ‘คJDuarteDJ

0๐Ÿ‘

The easiest way is PHP. Take a look here:

page1.php:

<body>
<?php include('menu.html'); ?>
page 1 content
page 1 content
</body>

page2.php:

<body>
<?php include('menu.html'); ?>
page 2 content
page 2 content
</body>

pageinfinite.php:

<body>
<?php include('menu.html'); ?>
pageinfinite content
pageinfinite content
</body>

and on: menu.html

<a href="page1.php">Page 1</a>
<a href="page1.php">Page 2</a>
<a href="page1infinite.php">Page infinite</a>

if you will add another item in menu.html, it will appear on every page!

Nice, huh?

๐Ÿ‘คuser2062658

Leave a comment