Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • james matson 7 posts 77 karma points notactivated
    Jun 27, 2019 @ 03:16
    james matson
    0

    Two beginner level issues with Umbraco

    Note: I am a beginner to using Umbraco.

    I have decided to try Umbraco out, so I have created an Umbraco installation in Azure, which looks something like this;

    Umbraco install on Azure

    It's working fine, however I have come up with two issues I don't understand (clearly because Umbraco is new to me).

    I used the beginner tutorial to create a document type, template etc. which has worked fine and allowed me to create this home page:

    https://umbraco-test.azurewebsites.net/homepage

    However, I then tried to create another page, no document types etc, just a HTML page using a cut and paste of the HTML from the homepage, but placed it under the HomePage, like this (selecting HomePage as the master template)

    enter image description here

    My thinking here, was trying to test how to make URL paths for my pages, e.g. www.site.com/homepage/subpage/page1 however if I try to view https://umbraco-test.azurewebsites.net/homepage/subpage

    I get:

    Server Error in '/' Application. Runtime Error Description: An application error occurred on the server

    If I place SubPage in the same place in the hierarchy as HomePage, (so no Master Template) like this:

    enter image description here

    Then I can browse the page via https://umbraco-test.azurewebsites.net/subpage. I'm not sure what I'm doing wrong here? Second issue, is even though the page is viewable in the second example, I have one umbraco field of body text (which is literally just some testing text) referenced in the SubPage template as

    @Umbraco.Field("bodyText")

    But in the rendered page, it shows up as per below - { "NAME": "1 COLUMN LAYOUT", "SECTIONS": [ { "GRID": 12 and so on;

    enter image description here

    This is an issue I can't figure out, as I reference the exact same field in my HomePage template (from which SubPage is a cut and paste) and it renders fine, see below:

    enter image description here

    Help me experts of Umbraco :) Your help will assist me with verifying Umbraco is a good fit for a commercial project I'm working on for my work.

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Jun 28, 2019 @ 08:03
    Marc Goodson
    0

    Hi James

    Welcome to the forums.

    I think the thing to get in your head is the following.

    In the Settings section: A document type defines the properties that an editor would fill the content of a page into.

    In the Content section The editor can create pages and site structure based on the document type configurations and enter the content for each page. These content pages define the url to the outside world. So create a content item in the context section called 'My Home Page' based on the Homepage document type, it will have the url / as it is the root page of the site - if the homepage document type allows a landing page document type to be created underneath, the editor will be able to create a new page underneath the My Home Page,perhaps called 'My Super Landing Page' and this will have url /my-super-landing-page - perhaps under the Landing Page document type you allow a 'Standard Content Page' to be created, the editor can then create an 'About us' page under 'My Super Landing Page' and the url would be /my-super-landing-page/about-us

    Each different document type can have a template (or multiple templates for editors to choose from).

    so when you create a page of 'Landing Page Type' it will look in the LandingPage template (in the settings section) for the html to use for that page.

    Because different page templates can share common html, it's possible to create a template 'underneath' a master layout template or section layout template - but this does not affect the url! nor affect whether an editor can or can't create a type of page underneath another page - it's just for sharing common elements like header and footer across multiple different page types.

    Bonus confusion here:

    Umbraco has a convention that if you want to force any page to load with a template different to the one the editor has chosen (on the info tab) you can force it to do so by passing the name of the alternative template on the querystring eg:

    /my-super-landing-page/about-us?altTemplate=landingPage

    would force our about-us page to load with the landingPage template which is nonsense as it's probably not got the correct properties that are required for that template, it will throw an error... so there are only niche scenarios where this is a useful trick to employ... however ... it can catch people out because

    /my-super-landing-page/about-us/landingPage.aspx

    has become a short cut to doing the above trick...

    as has

    /my-super-landing-page/about-us/landingPage

    so in your example: as you have no page published called subpage in your content section, but you do have a template matching that name your url:

    https://umbraco-test.azurewebsites.net/subpage

    is loading the 'homepage content' with the 'subpage' template... which isn't what you want, and is why you see errors.

    So if any of the above makes sense!

    Create a new doc type called RawHtmlSubPageTest - it will generate a template called RawHtmlSubPageTest - add some test html to the template.

    Go to your Homepage document type - from permissions - allow RawHtmlSubPageTest to be created underneath Homepage.

    Go to Content section - create a new page called 'Raw Test' based on the RawHtmlSubPageTest doc type. publish. url should be /raw-test - visit the url and it should show the html from your template.

    Hope that gets you further down the road!

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft