Copied to clipboard

Flag this post as spam?

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


  • Mark Watson 118 posts 384 karma points
    May 30, 2018 @ 04:37
    Mark Watson
    0

    Documentation for newbies

    I am beginning to work out what all the coding means. However I have a few staff that I would like to learn razor as well.

    The initial videos are fine to follow but when you are past the basics and looking at simple coding that most sites need like hiding empty fields you need to search online for examples and this takes a while.

    As a business owner I am a little concerned that learning by trial and error will take a long time and is not commercially viable for my paid staff. After all they will be expected to be paid while they are learning.

    Is there any courses or central documentation to teach the basics other than online searches?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 30, 2018 @ 05:55
    Jan Skovgaard
    0

    Hi Mark

    It would no doubt be very beneficial to send your staff on Umbraco training, which you can read more about here https://umbraco.com/training/

    Which parts of the documentation have you been exploring? And is it more examples you need for different contexts? I think it's also a question about defining a line between what is Umbraco specific and what is Razor specific since Razor is of course something that one can learn outside of an Umbraco context as well.

    But perhaps some of the examples found in the documentation can be extended for more use cases.

    /Jan

  • Mark Watson 118 posts 384 karma points
    May 30, 2018 @ 06:23
    Mark Watson
    0

    Thanks Jan

    I am replicating our more simple sites to see if umbraco is a fit for us. We have the basics of umbraco by following the videos and built the site structure, but finding hard to find the appropriate razor syntax/examples to display what we want to.

    I looked at the cost of a single course here in Sydney ($1,000) x 5 courses x 4 staff ($20,000 + wages). That is alot of web sites. And then which course do we need as there is no documentation on what the courses cover.

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    May 31, 2018 @ 06:45
    Dennis Aaen
    1

    Hi Mark

    You can find course details for all our different courses here

    https://umbraco.com/training/course-details/

    Hope this helps,

    /Dennis

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jun 14, 2018 @ 11:22
    Jan Skovgaard
    0

    Hi Mark

    I was reminded that it's actually also possible to do online training. It was announced at CG17 but I simply forgot about it untill HQ published this post today about online training: https://umbraco.com/blog/news-from-the-world-of-umbraco-training/

    You should be able to learn more about the online training options here https://umbraco.com/training/book-courses/fundamentals-online/

    Just thought I would mention it if it could be of interest :)

    Happy coding mate!

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    May 30, 2018 @ 07:41
    Jan Skovgaard
    0

    Hi Mark

    Ok, but can you provide some scenarios of what it is that you're having issues with figuring out how to render using Razor? Is it rendering of images, lists, reusable content, dropdowns etc? If you can provide some more detailed examples then it will be easier to think about how the documentation can be improved to take these scenarios into account since the current documentation maybe assume to much knowledge.

    Yes that is indeed a lot of money. But perhaps the approach could be to send 1 or 2 of your developers and then let them share the knowledge they gain internally after getting back from the course? Then over time you can send 1 or 2 more to get certified if needed for instance? - You could also try to get in touch with Umbraco HQ and learn more about what the courses cover and tell them what your needs are and maybe you can sort something out?

    EDIT: Perhaps the "On-Site" training could be an option? https://umbraco.com/training/on-site-training/ - I know the page does not mention any tutors in Australia but I don't think that should scare you of since I think that there actually are tutors in Australia too. But of course I don't know if it's within the distance of your office. But maybe that's an option?

    /Jan

  • Mark Watson 118 posts 384 karma points
    May 31, 2018 @ 06:08
    Mark Watson
    0

    Thanks Jan

    We are a team of Designers familiar with html, css, javascripting and Business Cataylst, not coders, so we understand the concepts and structures but need to know what the actual words mean. For example We were given the following in answer to one of our posts

    @if(Model.Content.HasValue(eventEndDate)){ Do something if the field has a }
    

    We did not understand what this meant (Model? Content?) The second post was more suscinct.

    @if(item.HasValue(“eventEndDate”)){@item.GetPropertyValue("eventEndDate").ToString(" dddd dd/MM/yyyy")}
    

    And this worked for us. We need to understand what the particular words in the structures mean and how to use them in the structures.

    Hope this explains where we are coming from.

  • Lewis Smith 208 posts 617 karma points c-trib
    May 31, 2018 @ 07:40
    Lewis Smith
    3

    Hi Mark,

    The best way to find out what is happening is to use VS, throw in a break point and explore what is being returned.

    Model is your current fields, so if you were to add a textstring with the document type of headerText, then if you were loading the page that had this document type you would be easily able to get this property.

    Model.Content.GetPropertyValue<string>("headerText") 
    

    Hope that makes sense.

    In most cases there are a few different way of retrieving content. By default you have to use Model.Content to retrieve fields, you can change this by changing the inherits code at the top of the template to :

    @inherits UmbracoViewPage<IPublishedContent>
    

    I'm not sure on the benefits of this other than now you dont have to call Model.Content you can just call Model.

    One thing that took me a while to understand is IPublishedContent. IPublishedContent is basically a custom Model. So when you render a page with properties you get the default properties such as Name (Model.Name), Url (Model.Url) (as well as a lot more, throwing in a breakpoint when rendering the Model will allow you to view these) IPublishedContent is basically the same as this. For example, when rendering an image, instead of being returned just the image url, you will be returned IPublishedContent. This allows you to get not only the image url but image id, image url absolute (image url with the full website path) again there are lots more things returned, this is just a simple example.

    Another key feature is being able to pull data from any page. https://our.umbraco.org/documentation/reference/templating/mvc/querying has some good docs about this. But in essence, you can just to the homepage by calling Model.Site()then you can work through the descendants of this page by calling Model.Site().Descendant("settings"). You could then get a property of this page in the same way. Obviously its not smart to call Model.Site().Descendant("settings")on its own in case its null so a good way is to null check this.

    var homePage = Model.Site();
    var settings = homePage.Descendants("settings").FirstOrDefault();
    
    //Check if navigation is null. This is being rendered in a partial meaning the only purpose of this partial is to render the navigation.
    if(settings == null){
        return;
        //break this opertation by returning nothing.
    }
    
    var headerNavigation = settings.GetPropertyValue<IEnumerable<IPublishedContent>>("navigation");   
    if(headerNavigation  == null){
        return;
        //headerNavigation not found so return null
    }
    

    This is a few examples of how to use Razor with Umbraco. I recommend the training courses as these are what I used to learn fast, you are usually given a booklet as well meaning you can refer to them to keep learning / help colleagues out.

    Another great utility is this forum, everyone is friendly, replies are pretty good so if you get stuck just ask on here!

    Any further questions, let me know!

    Thanks, Lewis

Please Sign in or register to post replies

Write your reply to:

Draft