menu from database based on url

3 views
Skip to first unread message

Vincent

unread,
Jun 12, 2010, 8:17:07 PM6/12/10
to Django users
I am very much new to django and I assume this question has been
answered. I referance to a tutorial or example of what I am trying to
do would be great. i.e. don't feel you need to give me a long answer
unless you want to.

I am trying to make some improvements to pydocweb http://code.google.com/p/pydocweb/
It is used for scipy/numpy documentation editing. http://docs.scipy.org/numpy/Front%20Page/

Currently the menu links are coded into the templates. I would like to
accomplish 3 things.
1. Store the list of menu links in a database table
2. make it simpler to add menu links
3. Have the menu items dynamic based on url

For example the current base template looks like (see below)

Thanks
Vincent

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="robots" content="noindex, nofollow" />
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{{MEDIA_URL}}/css/common.css"
type="text/css"/>
<link rel="stylesheet" href="{{MEDIA_URL}}/css/screen.css"
type="text/css" media="screen"/>
<link rel="stylesheet" href="{{MEDIA_URL}}/css/print.css"
type="text/css" media="print"/>
<script type="text/javascript" src="{{MEDIA_URL}}/js/jquery.js"></
script>
{% block extra_headers %}{% endblock %}
</head>
<body>
<div id="header">
{% for site in OTHER_SITES reversed %}
<div class="headertab">
<span><a href="http://{{site.domain}}/"
style="whitespace:nowrap;">&raquo; {{site.name}}</a></span>
</div>
{% endfor %}
<h1><a href="{% url pydocweb.docweb.views_wiki.frontpage
%}">{{CURRENT_SITE.name}}</a></h1>
</div>
<div id="navbar">
<ul>
<li class="button"><a href="{% url
pydocweb.docweb.views_wiki.frontpage %}">Wiki</a></li>
<li class="button"><a href="{% url
pydocweb.docweb.views_docstring.index %}">Docstrings</a></li>
<li class="button"><a href="{% url
pydocweb.docweb.views_stats.changes %}">Changes</a></li>
<li class="button"><a href="{% url
pydocweb.docweb.views_search.search %}">Search</a></li>
<li class="button"><a href="{% url pydocweb.docweb.views_stats.stats
%}">Stats</a></li>
{% if perms.docweb.change_docstring %}
<li class="button"><a href="{% url
pydocweb.docweb.views_control.merge %}">Merge</a></li>
{% endif %}
<li class="button"><a href="{% url
pydocweb.docweb.views_control.patch %}">Patch</a></li>
{% if user.is_superuser %}
<li class="button"><a href="{% url
pydocweb.docweb.views_control.control %}">Control</a></li>
{% endif %}
<li>&mdash;</li>
{% if user.is_authenticated %}
<li><b>{{user.first_name|escape}} {{user.last_name|escape}}</b>:</li>
<li class="button"><a href="{% url
pydocweb.docweb.views_user.password_change %}">Profile</a></li>
<li class="button"><a href="{% url django.contrib.auth.views.logout
%}">Log out</a></li>
{% else %}
<li class="button"><a href="{% url pydocweb.docweb.views_user.login
%}">Log in</a></li>
{% endif %}
</ul>
</div>
<div id="container">
<div id="title"><h1>{% block pagetitle %}{% endblock %}</h1></
div>
{% block actions %}{% endblock %}
<div id="content">{% block content %}{% endblock %}</div>
</div>
{% block below_container %}{% endblock %}
</body>
</html>

Reply all
Reply to author
Forward
0 new messages