Copied to clipboard

Flag this post as spam?

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


  • Meni 271 posts 507 karma points
    Apr 22, 2013 @ 00:33
    Meni
    0

    How to display articles / post in homepage?

    Hello,I try move my magazine to Umbraco.

    So basically I have in general 3 types of document types:

    Home page - which is the home page

    Magaizne page - which is the archieve by categories (sport / tech / music / etc)

    News page - which is the ongoing news, which have the properties: title, SubTitle, articleImg - which is media picker for the main article image, and articleText - which is it's the article text (rich text editor)

    Now what I try to do is to display the title and SubTitle on the home page for each category. As well as in the Magazine pages - which is basically the archieve. So, in the home page I need to display in each div between 4 to 8 posts of each category, and in the magazine pages each category has it's own page (sport / tech / music / etc)

    The question is: How do I do it???

    In wordpress theme it's very simple - I just using the php loop for each category. How does though I do it in Umbraco?? (Version 6, with Razor). I'm not using uBlogsy.

    Is there any simple way to do it? Any simple script / handler / helper jsut to show on homepage Image (Thumbnail) then title (under h1) and SubTitle (under h2) for each category? As well as in the archieve pages?

    I'm new to Umbraco and didn't find any tutorial how to do it. 

    Thanks so much!

    Meni .

  • Simon Deighton 23 posts 53 karma points
    Apr 22, 2013 @ 13:20
    Simon Deighton
    0

    Firstly I would create some partials that are going to display your magazines, news etc to keep it nice and neat.

    The magazines one sounds a little more difficult that news but for news I would create a partial called "_newsDisplay" then in partial could you try something like the below? :

    @{IPublishedContent newsNode = Umbraco.Content(THE ID OF YOUR NEWS PAGE);}

    @foreach (var newsItem in newsNode .Children().Take(4))
        {
            @{
            if (@newsItem.HasValue("newsThumb"))
            {
                var mediaItem = Umbraco.TypedMedia(@room.GetPropertyValue("newsThumb"));
                <img src="@mediaItem.GetPropertyValue("umbracoFile")"  />
            }
        }
        <p><a href="@newsItem.NiceUrl()">@newsArticle.Name</a></p>
        <p>@newsItem.GetPropertyValue("newsDescription")</p>
    }

    Then place your partial on the homepage like below :

    @Html.Partial("_newsDisplay")

    Im sure someone can correct me if im giving you the wrong assistance!

Please Sign in or register to post replies

Write your reply to:

Draft