Creating Pages and Using the Master Template
Last updated
Last updated
We are now going to create a page where we put our contact details. For added functionality, you might want to look at replacing this with a fully fledged contact us form.
Some potential solutions:
If you're not a programmer you can use the Umbraco built-in package - Umbraco Forms. Umbraco Forms has the added benefit that editors can also create their own forms. Find more information and purchase the product through Umbraco Apps.
Build your own contact form using Surface Controllers.
Let's create a content-only contact page where we can provide a title and some rich text.
Go to Settings.
Select the ... next to the Document Types in the Settings tree.
Select Document Type with Template. The Document Type opens in the content editor.
Select an Icon from the list of icons.
Enter a Name. Let's call it Simple Content Page.
Enter a Description.
Let's add two fields with the following specifications:
Group | Field Name | Alias | Data Type |
---|---|---|---|
Click Save.
Go to Templates to view your Simple Content Page template that was created automatically with the Document Type.
Select the Simple Content Page template and then select Master as the Master template.
Add the following HTML to the Simple Content Page template and click Save.
Click Save.
We now need to update the Document Type permissions to specifically add child nodes under the root content node.
To update the Document Type permissions:
Go to Settings.
Open the Homepage Document Type and go to the Permissions tab.
Select Add child in the Allowed child node types. The Choose child node dialog opens.
Select Simple Content Page and click Save.\
To create a content node:
Go to Content.
Select ... next to the Homepage and select Simple Content Page.
Enter a name for the Document Type. Let's call it Contact Us.
Fill in details for the Page Title and Body Text.
Click Save and Publish.
To add the Document Type properties:
Go to Settings.
Select Templates from the Templating section, and open the Simple Content Page template.
Scroll to the <!-- Jumbotron, w title -->
(around line 8) section and highlight the text “Umbraco Support”
(around line 11).
Click Insert and select Value.
Select the pageTitle field from the drop-down list and click Submit.
Repeat the same process for the <div class="container">
tag:
Highlight the content from the <p>
tag (around line 19) to the end of the </p>
tag (around line 22).
Click Insert and select Value.
Select bodyText field from the drop-down list.
Click Submit.
Click Save.
To view the Contact Us Page:
Go to Content.
Select the Contact Us page.
Go to the Info tab.
Click the link to view the page. \
You may notice that the footer is now empty - we don't have the content from our Homepage node.
To use the Document Type properties from the homepage, do the following:
Go to Settings.
Select Templates from the Templating section, and open the Master template.
Highlight @Model.Value("footerText")
in the footer (around line 52) and click Insert.
Select Value and choose the footerText again from the Choose field dropdown.
Select Yes, make it recursive checkbox. This notifies Umbraco to look up the content tree if the field doesn't exist at the node level for the page we're requesting.
Click Submit.
Click Save.
Reload the Contact Us page to view the content with the footer.
Content
Page Title
pageTitle
Textstring
Content
Body Text
bodyText
Rich Text Editor