Copied to clipboard

Flag this post as spam?

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


  • David Gregory 82 posts 208 karma points
    Sep 15, 2015 @ 09:42
    David Gregory
    0

    User editable content snippets?

    Hi guys

    Sorry if I am bombarding the forum, lost of newbie questions I'm afraid.

    I want to have section of content that can be edited by my users but the content in itself is not a page.

    For example, it could be contact details that would appear in the footer of every page. I could easily hard code this into the footer of the template but that way a user couldn't edit the details if the need arose.

    Can I give them a section where they can edit snippets of content that can then appear at various places throughout the site?

    David Umbraco 7.2.8

  • LeszekP 27 posts 78 karma points
    Sep 15, 2015 @ 09:48
    LeszekP
    0

    Hi David,

    Create doctype - UserEditableContatWrapper. Under that add doctype with properties you want, like a textstring, call it footerText. Add property umbracoNaviHide and set it, so it won't be rendered in menu.

    In template render it.

    Hope somebody could better explain it to you.

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Sep 15, 2015 @ 10:00
    Dennis Aaen
    0

    Hi David,

    Here is the way how I would solve this. I assume that you have a frontpage document type (http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/document-types/what-is-a-document-type/)

    On the frontpage document type I would create a tab called site settings. In there I would add fields for the address. It could be text strings data types or it could be one multiple textbox. http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/document-types/properties/ and http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/document-types/data-types/

    Then you would need to get the data out in your template, this can simple be done using this.

    @Umbraco.Field("propertyAlias", recursive: true)
    

    You will need to change the propertyAlias to your alias of the field that you want to pull out

    It´s also on the site settings tab I would add e.g Google analytics id field and stuff like that.

    Hope this helps,

    /Dennis

  • David Gregory 82 posts 208 karma points
    Sep 15, 2015 @ 10:07
    David Gregory
    0

    With that option, do all other doctypes have to inherit from the frontpage?

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Sep 15, 2015 @ 10:18
    Dennis Aaen
    100

    Hi David,

    No, they sould not in inherit, the recursive: true goes up in the content tree until it finds the field, and the field has a value.

    Try to see this videos as well, I am sure that they can help you too.

    http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/document-types/master-document-type/

    http://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/templating/introduction/

    /Dennis

  • David Gregory 82 posts 208 karma points
    Sep 15, 2015 @ 10:21
    David Gregory
    0

    I'll give that a whirl, thanks.

  • David Gregory 82 posts 208 karma points
    Sep 15, 2015 @ 13:05
    David Gregory
    0

    That worked perfect. Quick question though, how would I do the same thing with an image? If I had a media picker on the homepage that represents a banner image?

    i've been using this to get it once:

    <img src="@Umbraco.Media(CurrentPage.bannerImage).Url" ...

  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Sep 15, 2015 @ 18:27
    Dennis Aaen
    0

    Hi David,

    If you want to use the a media picker on the homepage, then you can get the image using this Razor.

    @{ 
        if(CurrentPage.HasValue("bannerImage")){ 
            var bannerImage = Umbraco.Media(CurrentPage.bannerImage);
            <img src="@bannerImage.umbracoFile alt="@bannerImage.Name" />
        }
    }
    

    Hope this helps,

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft