====== Django-cms-themes ====== ===== Using themes form www.djangocmsthemes.com ===== User can use an app to download themes from the website and upload/apply them using 'admin' interface. **It does not work properly at the moment** http://www.djangocmsthemes.com/getting-started install the django-cms-themes pluggable django app. The best way to do this is to use the command "pip install django-cms-themes" (if you are using pip). Add 'cms_themes' to INSTALLED_APPS in your settings file. Make sure you have a setting in your settings.py file called PROJECT_DIR, which should point to the root of your project in the filesystem, i.e. PROJECT_DIR = os.path.abspath(os.path.dirname(__file__)) Run "python manage.py syncdb" (or "python manage.py migrate" if you have south installed). ===== Making your own themes based on www.djangocmsthemes.com ===== ==== download and extract themes ==== Themes for the website are installed to 'themes' folder inside your webroot. CSS links and images are configured with this default path. [td@localhost vfoss_cms]$ tree themes themes ├── simple │ ├── static │ │ ├── css │ │ │ └── style.css │ │ └── images │ │ ├── bullet.png │ │ ├── graphic.png │ │ ├── paperclip.png │ │ └── pattern.png │ └── templates │ └── index.html └── summer ├── static │ ├── css │ │ └── styles.css │ ├── images │ │ ├── 1.jpg │ │ ├── 2.jpg │ │ ├── 3.jpg │ │ ├── 4.jpg │ │ ├── body-bg.jpg │ │ ├── tabs_1.gif │ │ └── tabs_2.gif │ └── js │ ├── jquery-1.3.2.min.js │ ├── jquery.cycle.all.min.js │ ├── script.js │ └── superfish.js └── templates ├── content.html └── index.html === Edit settings.py to make these themes available as templates === -------- settings.py ------------ ... 77 STATICFILES_DIRS = ( 78 os.path.join(PROJECT_DIR, 'static_dev'), 79 os.path.join(PROJECT_DIR, 'themes'), 80 ) ... 100 CMS_TEMPLATES = ( 101 ('example.html', 'Example Template'), 102 ('template_1.html', 'Template 1'), 103 ('template_2.html', 'Template 2'), 104 ('summer/templates/index.html', 'summer'), <===== make index.html a template. 105 ) 106 107 ROOT_URLCONF = 'urls' 108 109 TEMPLATE_DIRS = ( 110 os.path.join(PROJECT_DIR, 'templates'), 111 os.path.join(PROJECT_DIR, 'themes'), <==== add template dir. 112 ) 113 ... It's avisable to use a template folder with the same structure as above. Create 'index.html' ** Add 'themes' to STATICFILES_DIR then use \{\{ STATIC_URL \}\}theme_name/static as path to static files ** 1 {% load cms_tags menu_tags sekizai_tags %} 2 3 4 5 6 7 8 9 10 11 12 {{ request.current_page.get_title }} 13 {% render_block "css" %} 14 15 16 17 {% cms_toolbar %} 18 19
20 21
22 23 31 32 37 {% block slider %} 38
39 40
41 {% placeholder "slider_images" or %} 42 {# show_placeholder "slider_images" request.current_page.get_home_pk_cache #} 43 image 44 image 25 {% show_placeholder "header" request.current_page.get_home_pk_cache %} 26 28 {% endplaceholder %} 29
30
31 32 37 {% block slider %} 38
39 40
41 {% placeholder "slider_images" or %} 42 {# show_placeholder "slider_images" request.current_page.get_home_pk_cache #} 43 image 44 image 45 image 46 image 47 {% endplaceholder %} 48
49 50
51
52
    53
54
55
56
57
58 59 {% endblock %} 60 61 62
63 71 72
73 {% placeholder "content-top" or %} 74 {% endplaceholder %} 75
76
77 {% placeholder "content-left" or %} 78 {% endplaceholder %} 79
80 84
85
86 {% placeholder "content-bottom" or %} 87 {% endplaceholder %} 88
89 90 91
92 93
94 95
96 97
98 99 102 103 {% render_block "js" %} 104 105
==== template tags explained ==== * https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs * http://docs.django-cms.org/en/2.1.3/advanced/templatetags.html * https://docs.djangoproject.com/en/dev/topics/templates/#variables == placeholder == Place holder is put where dynamic content is desireable. Django-cms will allow page editor to replace it with one of the plugins. {% placeholder "name" or %} anything withing this block... {% show_placeholder "header" request.current_page.get_home_pk_cache %} ... will be displayed if no plugin is input or the plugin returns no output. {% endplaceholder %} == show_placeholder == Show a specific placeholder from a given page. This is useful when a content should be used in many pages. Arguments: * placeholder_name * page_lookup (see Page Lookup for more information) * language (optional) * site (optional) {% show_placeholder "header" request.current_page.get_home_pk_cache %} == page lookup == The page_lookup argument, passed to several templatetags to retrieve a page, can be of any of the following types: * String: interpreted as the reverse_id field of the desired page, which can be set in the “Advanced” section when editing a page. * Integer: interpreted as the primary key (pk field) of the desired page * dict: a dictionary containing keyword arguments to find the desired page (for instance: {'pk': 1}) * Page: you can also pass a page object directly, in which case there will be no database lookup. If you know the exact page you are referring to, it is a good idea to use a reverse_id (a string used to uniquely name a page) rather than a hard-coded numeric ID in your template. For example, you might have a help page that you want to link to or display parts of on all pages. To do this, you would first open the help page in the admin interface and enter an ID (such as help) under the ‘Advanced’ tab of the form. Then you could use that reverse_id with the appropriate templatetags: {% show_placeholder "right-column" "help" %} Help page If you are referring to a page relative to the current page, you’ll probably have to use a numeric page ID or a page object. For instance, if you want the content of the parent page display on the current page, you can use: {% show_placeholder "content" request.current_page.parent_id %} Or, suppose you have a placeholder called teaser on a page that, unless a content editor has filled it with content specific to the current page, should inherit the content of its root-level ancestor: {% placeholder "teaser" or %} {% show_placeholder "teaser" request.current_page.get_root %} {% endplaceholder %} == block == Block tags tell template engine that a child page, which extends this template, may overwrite these portions of the template. {% block block_name %}