Copied to clipboard

Flag this post as spam?

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


  • Michael Jensen 35 posts 85 karma points
    Feb 15, 2012 @ 13:20
    Michael Jensen
    0

    Showe images from a proppety

    Hey.

    iam tryning to get a script waren uses in the 5 episode ware he liste the news

    i nees it to show a category images above the test. 

    The reason is look to use this is so the site kan make new categories when it is neede.

    i have look in forum and havent found wath i think can help

    the propety i like to use has this Alias KategoriBillede 

     

    my file looks like tihis.

    <div class="newsList">
        @{
            @-Setup counter variable for position -*@
            var position 1;
        }

        @-List children pages from the current page (aka Model-*@
        @foreach (var page in @Model.Children.Where("umbracoNaviHide != true"))
        {
            <div class="left">         
                @-Display the name of the page link -*@
                <h4><href="@page.Url">@page.Name</a></h4>
            
                @{
                    var bodyText         @page.bodyText.ToString();
                    var bodyTextNoHtml   umbraco.library.StripHtml(bodyText);
                    var bodyTextTrunc    umbraco.library.TruncateString(bodyTextNoHtml150"...");
                }
                
                <p>
                   i like the images right heer 
                </p>
                <p>
                    @bodyTextTrunc
                </p>
            </div>
            
            @-After every 3rd item insert <br/-*@
            if (position == 0)
            {
                <br/>
            }
            
            @-Increase the position counter by -*@
            position++;
        }
    </div>

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 15, 2012 @ 14:45
    Tom Fulton
    0

    Hi,

    Is your property KategoriBillede using the Media Picker datatype?  If so you can do something like

                @{
                    var bodyText         = @page.bodyText.ToString();
                    var bodyTextNoHtml   = umbraco.library.StripHtml(bodyText);
                    var bodyTextTrunc    = umbraco.library.TruncateString(bodyTextNoHtml, 150, "...");
                    var media         = Library.MediaById(page.KategoriBillede);
                }
               
                <p>
    <img src="@media.umbracoFile" />             </p>
                <p>
                   @bodyTextTrunc
                </p>

    Hope this helps,
    Tom

  • Michael Jensen 35 posts 85 karma points
    Feb 15, 2012 @ 15:07
    Michael Jensen
    0

    the images is uploaede via uploadet propety via generic proppetyes type Upload.

    i tryed you post and it do not work.

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Feb 15, 2012 @ 15:09
    Tom Fulton
    0

    Ahh ok, my example was for a media picker.  If it's an Upload datatype it's actually a little easier since it stores the path to the image instead of an ID:

                @{
                   
    var bodyText         =@page.bodyText.ToString();
                   
    var bodyTextNoHtml   = umbraco.library.StripHtml(bodyText);
                   
    var bodyTextTrunc    = umbraco.library.TruncateString(bodyTextNoHtml,150,"...");
                }
               
               
    <p>
                   
    <img src="@page.KategoriBillede"/>
               
    </p>
                <p>
                   
    @bodyTextTrunc
                </
    p>

    -Tom

  • Michael Jensen 35 posts 85 karma points
    Feb 15, 2012 @ 16:21
    Michael Jensen
    0

    Thanks it works like a charmmm

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies