-
- 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
View blog entry
The view blog entry is the much of the same as the viewarticle, but we will add a sidebar listing related documents and a list of the latest. So the first we do is simply to create a new page based on the viewarticle and get a quick start on this one.
<div class="row"> <div class="col-md-10"> <div class="row"> [{ maindata.body|safe }] </div> <div class="row"> <div class="col-md-12 text-right"> Created: [{ maindata.createddate }] - [{ maindata.createdtime }] Last updated: [{ maindata.updateddate }] - [{ maindata.updatedtime }] <a class="bnt btn-xs btn-primary" href="/cms/editarticle/0/?slug=[{ maindata.slug }]">Edit</a> </div> </div> </div> <div class="col-md-2"><br>
We do a change to the code to tell the type and make ready for the side view. The sideview we create by adding the start of the structure at the topmost box in the page and add dataviews and a final box at the bottom that closes the sideview. We do turn of outer html in all boxes and dataview to be able to write all the html code to be used our self. In this case it can be of interest to see the output generated by the code generator in DG3 for debugging purposes.
<li [% if maindata.id == viewdata.id %]class="active"[% endif %]> <a href"/blog/viewblogentry/?id=[{ viewdata.id }]">[{ viewdata.title }]</a> </li><br>
The dataview code simply list all entries it gets and do a check for the currently loaded entry to make that active in the list. We use a Bootstrap component stacked pills as the looks for the list, bet here you can use whatever iteratable element you like. Ex table, divs, ps etc. To make the element you add the start tag to view header and end tad to view footer. In this case <ul class="nav nav-pills nav-stacked"> to view header and </ul> to view footer.
</div> <!-- for <div class="col-md-2">--> </div> <!-- for <div class="row">--><br>
The final box code, I like to add comments to what div I close to make the code easier to follow.
The final result with one entry on screen and a few other listed at the side
Showing our main entry with content and our title of the other entries at the side with newest on top.