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 %][{ }][% 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:

Redirect OK/blog/viewblogentry/?ID=[[ id ]]
Redirect fail/blog/viewblogentries/
The new redirect for the button delete are:
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.