Monday, January 14, 2013

Django-cms navigation / menu example


1. project structure:

django-cms_project_dir/
    .
    |-- templates (dir)
    |    `-- example.html
    |-- __init__.py
    |-- manage.py
    |-- settings.py
    |-- urls.py
    |-- ..

2. create file:
./templates/example.html

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{% load cms_tags menu_tags sekizai_tags %}
<!doctype html>
<head>
  <title>{{ request.current_page.get_title }}</title>
  {% render_block "css" %}
</head>

<body>
<p>
    {% show_menu 0 100 100 100 %}
</p>
{% cms_toolbar %}
    {% placeholder "main" %}
{% render_block "js" %}
</body>
</html>

2. add to file:
./settings.py

1
2
3
CMS_TEMPLATES = (
    ('example.html', 'Example Template'),
)




3. create several pages through django-cms "admin" page:
("Add page" and "Save and continue editing")

4. drag and drop subpages into "home" page:

5. view "home" page:

...that's all

No comments:

Post a Comment