-
- What is DG3
- The different components
- Requirements for running DG3
- Installation of DG3
- Additional installation steps
- Select which web server to use
- Hello World application
- Intro to CMS
- Setting up DG3 as a CMS
- Editing pages
- More about pages and urls
- Structuring a page using the grid
- Adding menu to pages
- Add images to the application
- More formating
- Sending email from contact us
- Adding menu to template
- Deploy the web site
- Storing the pages in database
- Create record
- Auto fill field
- Field validation
- Enable save button validator
- Add new button to template
- View document
- List documents
- Fix selection in menus in template
- CRUD Create Read Update Delete
- Intro to blogs
- Add user authentication
- Bootstrap authentication
- Let user change their passords
- Add reset password
- Login dialog box
- Extending the CMS to a blog
- Extend table for blogging
- Edit blog entry
- View blog entry
- User registration
- User password validation
- User field validation
- User auto login
- User extra registration fields
Fix selection in menus in template
Since we now want to use the documents in the cms in the template menus, we have to change the way the menus are selected, To do this, we will change the context view once more to take the cms into consideration. In the new solution we want to keep the contact page from the first iteration since that has a for for sending mail, but to home page and about page should be highlighted in the menu when opened from the cms. This is how it can be solved.
Context view handling the cms
First of all the contact can be handled as before, but home and about gives back cms as current. We can use that to do a check for the used slug when pages form the cms is shown and add that to a different livetext.
path = request.get_full_path()[1:-1] # remove the leading and trailing / current = path.split('/')[0] ctx[ 'current'] = current if current == 'cms': try: slug = request.GET.get('slug') ctx['slug'] = slug except: passThe new code in context view
<div class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li class="{% if slug == "landing-page" %}active{% endif %}"><a href="/cms/viewarticle/?slug=landing-page">Home</a></li> <li class="{% if slug == "about" %}active{% endif %}"><a href="/cms/viewarticle/?slug=about">About</a></li> <li class="{% if current == "contact" %}active{% endif %}"><a href="/contact/">Contact</a></li> </ul>The new menu code in the template
Make sure the default page is the right one
When we created the first version of the solution, we selected the landing page as the default page for the application. It still is, so when we first visits the cms, we will start with the old page and not the new editable page form the Articles table. Since we can not select a page with a query string as the default page, we have to make the landing page do a redirect the the new landing page in the CMS. This is how to do it.
- Open the original landing page
- Change the redirect in page properties settings tab to /cms/viewarticle/?slug=landing-page by first selecting the /cms/viewarticle/ from the dropdown and then add the page query string ?slug=landing-page
