-
- 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
Edit blog entry
Create a editblogentry based on editarticle
When you want to create a form similar to another, the best way is to use the page based on. This will give you an exact copy of the page you base it on. In DG3 you can not copy html code that contains fields or snippets since these have values set on then that is not contained in the html code. By using create page based on, you will get these values as well as the html code.
The only new will be the extras for a blog like tag, author that comes from user, the type that now have to default to blogentry and the redirects for save and delete buttons.
<h3>[% if xdg3.url.recordno == -1 %]Create a new blog entry[% else %]Edit blog entry[% endif %]</h3> [! field id !][! field type !][! field author !] <div> <div> <label for="">Title</label> [! field title !] </div> </div> <div> <div> <label for="">Lookup url</label> [! field slug !] </div> <div> [{ maindata.createddate }] - [{ maindata.createdtime }] </div> </div> <div> <div> <label for="">Tag</label> [! field tag !] </div> <div> [% if maindata.author %][{ maindata.author }][% else %][{ user.username }][% endif %] </div> </div> <div> <div> [! field body !] </div> </div> <div> <div> [! button save !] </div> <div> [! button delete !] </div> </div>
The new edit page code. There is one new interesting element here: we do a check to see if we have the author in maindata and if not we show the username form user. This is done to be able show the username before we have save any to the table.
The new redirect for the button save are:
The new redirect for the button delete are:Redirect OK /blog/viewblogentry/?ID=[[ id ]] Redirect fail /blog/viewblogentries/ Redirect OK /blog/viewblogentries/ Redirect fail /blog/viewblogentries/ Why create two pages editing the same recode data and not just one?
We could make on editarticle that also could handle the blog editing. We could use url query string to select one or the other and show or now show field based on this. There is one thing we not will be able to manage then, and that is the url for the page. So when combining more that one type of document in one page, you have to find a neutral name for your page. We made two version just to show that you can do that as well.