Copied to clipboard

Flag this post as spam?

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


  • Owain Williams 481 posts 1413 karma points MVP 7x c-trib
    Oct 14, 2015 @ 08:37
    Owain Williams
    0

    Add a page summary to homepage

    Hi all, I'm using the Grid Layout in 7.3 and I'm hitting a problem which I can't get my head around. What I want to be able to do is select a page within the back office which will feature on the homepage.

    I have a checkbox on my properties which has the type true/false

    What I would like to do is somehow display any pages that have the box checked on to the homepage within a 3 column row.

    I'm thinking I might need to work with a partial view to accomplish this but never very sure.

    Any help would be appreciated. I'm working my way through the Umbraco TV videos in the hope that might help as well. :)

    EDIT:

    So, I have my masterpage and then my Home template. Within the Home template I have

      @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "Master.cshtml";
    }
    @CurrentPage.GetGridHtml("content")
    
    @{ Html.RenderPartial("featuredArticles"); }
    

    Within my featuredArticles I have

    @{  
            var selection= CurrentPage.Children("TextPage").Where("featuredPage == true").Where("Visible");
            }
    
    
        @if (selection.Any())
        {
            <ul>
                @foreach (var item in selection)
                {
                    <li><a href="@item.Url">@item.Name</a></li>
                }
            </ul>
        }
    

    My content tree looks like this:

    Home
    -About
    -Pages
    --Page1
    --Page2 (featured True)
    

    Still trying to work out how to get the partial view in to my GridLayout as there only seems to be the option for Macros, do I need to convert the Partial view to a macro to use Grids.

    The above code also doesn't display the featured pages yet but I'm working on that as well!

  • Ben McKean 272 posts 549 karma points
    Oct 14, 2015 @ 10:14
    Ben McKean
    0

    For user experience (from an editors point of view), I'd say you'd be better giving the user the ability to choose pages they'd want to display on the home page from the home page. Otherwise it'll be a task to track down which pages have or haven't been checked.

    So then you'd want to create a new Grid editor type that uses a content picker.

    I've used the brilliant LeBlender before to achieve such things https://our.umbraco.org/projects/backoffice-extensions/leblender/

  • Owain Williams 481 posts 1413 karma points MVP 7x c-trib
    Oct 14, 2015 @ 13:12
    Owain Williams
    0

    Thanks Ben, just looking at the Blender option now. The setup instructions are a bit lacking though. Have you had any experience in setting it up?

  • Ben McKean 272 posts 549 karma points
    Oct 14, 2015 @ 13:24
    Ben McKean
    0

    It involves a few steps but you're effectively extending the functionality of the Grid. If you've not got much experience of the Grid you might be better off using another data type. Does it need to be a Grid i.e. does the user need that level of flexibility? If they do I can list the steps I took to achieve it :)

  • Owain Williams 481 posts 1413 karma points MVP 7x c-trib
    Oct 14, 2015 @ 13:32
    Owain Williams
    0

    If you wouldn't mind showing me the steps, I'd really appreciate it.

    Thanks,

  • Ben McKean 272 posts 549 karma points
    Oct 14, 2015 @ 13:53
    Ben McKean
    1

    Ok....although another one of the data types might be easier. Archetype for example would be perfect for this and a lot easier to set up imho.

    Official instructions are here

    1. install Le Blender - this will give you the ability to create other data types that can be used in the grid. This will give you a new item in the Developer section called Grid Editors
    2. In the Grid Editors section create a new editor, select Le Blender editor from the drop down
    3. Fill in the various details. The most important one here is Properties. Add a new property with the data type as Content Picker (this is what you'll use to choose the page you want to show a summary from)
    4. Then you'll need to create the views for the Grid Editor Type in Views\Partials\Grid\Editor. This is so you can render out what you want to in both Umbraco and on the front end website
  • Owain Williams 481 posts 1413 karma points MVP 7x c-trib
    Oct 14, 2015 @ 14:20
    Owain Williams
    0

    Thanks Ben, seems to be an issue with the namespaces.

    "The type or namespace name 'LeBlenderModel' does not exist in the namespace 'Lecoati.LeBlender.Extension' (are you missing an assembly reference?)"

    Not as straight forward as I had hoped! :)

  • Ben McKean 272 posts 549 karma points
    Oct 14, 2015 @ 14:33
    Ben McKean
    0

    Hmm, not sure about that one sorry. Did you have a look at Archetype? I really believe that could get you up and running quickly

  • Owain Williams 481 posts 1413 karma points MVP 7x c-trib
    Oct 14, 2015 @ 14:34
    Owain Williams
    0

    Can it be used with GridLayout as well? I'll look in to it. Thanks.

Please Sign in or register to post replies

Write your reply to:

Draft