11Customizing TOM Templates
22-------------------------
3-
43So you’ve got a TOM up and running, and your homepage looks something
54like this:
65
@@ -24,13 +23,30 @@ have a project layout that looks something like this:
2423 ├── urls.py
2524 └── wsgi.py
2625
27- We are going to override the html template included with the TOM
28- Toolkit, ``tom_common/index.html ``, so that we can edit some text and
29- change the image. Overriding and extending templates is `documented
26+ Using Themes
27+ ~~~~~~~~~~~~
28+ You can set the color theme for your TOM to "Dark Mode" by setting the `CSS_THEME = 'Dark' ` in your ``settings.py ``.
29+ If the theme doesn't seem to be working properly, make sure you aren't overriding key components in your
30+ `static/tom_common/css/custom.css ` file.
31+ |image2 |
32+
33+ Making your own pages
34+ ~~~~~~~~~~~~~~~~~~~~~
35+
36+ One very powerful, but more work intensive way to customize your TOM is
37+ to override the html templates included with the TOM
38+ Toolkit. In this example we are going to override the home page, ``tom_common/index.html ``, so
39+ that we can edit some text and change the image. Overriding and extending templates is `documented
3040extensively <https://docs.djangoproject.com/en/2.1/howto/overriding-templates/> `__
3141on Django’s website and we highly recommend reading these docs if you
3242plan on customizing your TOM further.
3343
44+ .. note ::
45+
46+ You should generally try to avoid overriding entire templates when possible, instead using integration points
47+ (described below) or overriding specific partials. This lets you continue to benefit from maintenance done to these
48+ pages by the TOM Development team without having to continually update your TOM's versions of these templates.
49+
3450Since the template we want to override is already part of the TOM
3551Toolkit source code, we can use it as a starting point for our
3652customized template. In fact, we’ll copy and paste the entire thing from
@@ -127,7 +143,7 @@ alone. Reload your homepage, and you should see something like this:
127143
128144|image1 |
129145
130- Thats it! You’ve just customized your TOM homepage.
146+ That's it! You’ve just customized your TOM homepage.
131147
132148Using static files
133149~~~~~~~~~~~~~~~~~~
@@ -162,14 +178,20 @@ Customize default CSS:
162178The default styling is mostly based on Bootstrap v4.6.2 (`https://getbootstrap.com/ <https://getbootstrap.com/ >`__).
163179If you ran the tom_setup script, you should have a directory ``static `` at the top level of your project.
164180Within this folder, find the ``tom_common/css `` directory. In this folder, is a file named ``custom.css ``.
165- Editing this file will allow you to overwrite any of the custom css used at the base level in the TOM Toolkit.
181+ Editing this file will allow you to overwrite any of the css used at the base level in the TOM Toolkit, including the
182+ styling established by TOMToolkit themes such as "Dark Mode".
183+
184+ The TOMToolkit has several built in variables that allow you to establish a theme for your TOM. You can see these in
185+ `root ` dictionay in yoyr ``custom.css ``. Altering these will change the appearance of large portions of the website.
166186
167187As an example, let's change the background color from white (#ffffff) to an off-white (#efead6).
188+ Add the following in your ``custom.css `` after the comments:
189+
168190
169191.. code :: css
170192
171- body {
172- background-color : #efead6 ;
193+ :root {
194+ --theme_primary : #efead6 ;
173195 }
174196
175197 Once you have added these images to the ``static/tom_common/img `` directory and reloaded the page (you may need to
@@ -255,3 +277,4 @@ for more details.
255277
256278.. |image0 | image :: /_static/customize_templates_doc/tomhomepagenew.png
257279.. |image1 | image :: /_static/customize_templates_doc/tomhomepagemod.png
280+ .. |image2 | image :: /_static/customize_templates_doc/darkmode.png
0 commit comments