Copied to clipboard

Flag this post as spam?

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


  • Stephen Davidson 216 posts 392 karma points
    Nov 22, 2012 @ 00:21
    Stephen Davidson
    0

    List blog posts in news rotator

    Hey All,

    I have the following code which i have adapated from the uBlogsy list posts razor to enable me to show the latest five posts on my home page carousel.

    The script is saving without issue and it looks good to me but I'm getting an error on the page:

    Error loading MacroEngine script (file: ListHomepageNews.cshtml)

    My code is as follows:

     

    @using System.Linq
    @using System.Xml.Linq
    @using umbraco.MacroEngines
    @using uBlogsy.Web.Extensions
    @using uBlogsy.Web.Helpers
    @{    

        // get all posts for homepage

        IEnumerable<DynamicNode> postList = new DynamicNode(Model.Id)

                                        .AncestorOrSelf(1)

                                        .DescendantsOrSelf("uBlogsyPost")

                                        .Items

                                        .Where(x => x.GetProperty("showOnHomepage").Value != "1");

     

        // get item count

        int count = int.Parse(@Parameter.ItemCount);

        List<DynamicNode> nodes;

            nodes = postList.OrderByDescending(x => x.GetProperty("uBlogsyPostDate").Value)

                            .Take(count)

                            .ToList();

    <div id="slider">

                    @foreach (DynamicNode n in nodes)

                    {

                        <div id="slide1" class="slide">

                            <a href="@n.Url">

                                <span>@n.GetProperty("mainImage").Value</span>

                            </a>    

                        </div>

                    }

    </div>

    <div id="accordion">

    @foreach (DynamicNode n in nodes)

                    {

                        <div class="link-header">

                            <a href="@n.Url">

                                <span>@n.GetProperty("uBlogsyContentTitle").Value</span>

                            </a>

    <div class="link-content">

                        </div>

                        </div>

                    }

    </div>

     }

     

  • Nigel Wilson 945 posts 2077 karma points
    Nov 22, 2012 @ 01:37
    Nigel Wilson
    0

    Hi Stephen 

    There is a plugin for Firefox that can assist in debugging your code

    https://addons.mozilla.org/EN-us/firefox/addon/umbraco-debug/

    Make sure you have the following set in your web.config tho...

    <add key="umbracoDebugMode" value="true" />

    And then ensure you set it to false when in a live environment

    Hope this helps.

    Nigel

  • Nigel Wilson 945 posts 2077 karma points
    Nov 22, 2012 @ 01:38
    Nigel Wilson
    0

    BTW - man, you are up late...

  • Mike Chambers 636 posts 1253 karma points c-trib
    Nov 22, 2012 @ 10:11
    Mike Chambers
    0

    you can also just use... www.domain.com/someumbracopage?umbDebugShowTrace=true when you've also set the appkey to true [<add key="umbracoDebugMode" value="true" />]

    to see a more descriptive error message. - nicely highlighted in red for the errors.

  • Stephen Davidson 216 posts 392 karma points
    Nov 22, 2012 @ 10:22
    Stephen Davidson
    0

    Ha! yes was up way to late...paying for it this morning! Thank you both for the debugging tips...will report back with solution hopefully!

    S

  • Stephen Davidson 216 posts 392 karma points
    Nov 22, 2012 @ 10:35
    Stephen Davidson
    0

    wierd, i'm not getting any other descriptive error messges?

     

    Am now sorry! PLease ignore!

     

  • Stephen Davidson 216 posts 392 karma points
    Nov 22, 2012 @ 21:47
    Stephen Davidson
    0

    Ok I got this working, just need to work out one last thing in Razor and i'm done. In the following seciton i need to change the ID of each Slider (see bold), so if there are 4 items back i need to change the id to Slider1, Slider 2, Slider3 etc.

     @foreach (DynamicNode n in nodes)
     {

    <div id="Slider1" class="slide">

                            <a href="@n.Url">

                                <span>@n.GetProperty("uBlogsyContentTitle").Value </span>

                            </a>
       </div>

               }

     

    TIA,

    S

  • Stephen Davidson 216 posts 392 karma points
    Nov 23, 2012 @ 09:12
    Stephen Davidson
    0

    okay geting a little closer...i'm using the index as follows, but i cant get the "slide" text to prefix the @n.index(), tried [email protected]() but no joy...bound to be simple i know...

    <div id="slider">

               

                    @foreach (DynamicNode n in nodes)

                    {

                        <div id='@n.Index()' class="slide">

                            <a href="@n.Url">

                             <img src="/[email protected]("blogmainImage").Value&width=800&height=400&Constrain=True" alt="@n.GetProperty("uBlogsyContentTitle").Value" title="@n.GetProperty("uBlogsyContentTitle").Value" />

                            </a>

                            <h2><span>@n.GetProperty("uBlogsyContentTitle").Value</span></h2>

                <h3><span>@n.GetProperty("uBlogsyContentTitle").Value</span></h3>

                  <div class="btnSlider">

                    <a href="@n.Url" alt="@n.GetProperty("uBlogsyContentTitle").Value" >@n.GetProperty("uBlogsyContentTitle").Value</a>

                  </div>

                        

                        </div>

                    }

    </div>

  • Stephen Davidson 216 posts 392 karma points
    Nov 23, 2012 @ 10:51
    Stephen Davidson
    0

    Feel like i'm talking to myself in here...first sign of madness?! :-)

    Ok after reading chapter 6 & 7 of the excellent Razor series i worked it out.  

     

    <div id="slider">
    @foreach (DynamicNode n in nodes)

                    {

                        int slidecount = @n.Index();

                        string cssid = "slide" + slidecount;

                        <div id='@cssid' class="slide">

                            <a href="@n.Url">

                             <img src="/[email protected]("blogmainImage").Value&width=800&height=400&Constrain=True" alt="@n.GetProperty("uBlogsyContentTitle").Value" title="@n.GetProperty("uBlogsyContentTitle").Value" />

                            </a>

                            <h2><span>@n.GetProperty("uBlogsyContentTitle").Value</span></h2>

                <h3><span>@n.GetProperty("uBlogsyContentTitle").Value</span></h3>

                  <div class="btnSlider">

                    <a href="@n.Url" alt="@n.GetProperty("uBlogsyContentTitle").Value" >@n.GetProperty("uBlogsyContentTitle").Value</a>

                  </div>

                        

                        </div>

                    }

    </div>

    Still not out of the woods though...i have noticed that the index is starting at 2 then 1 then 3, and i need them to be sequential...does this mean i cannot use Index()?

    S

     

  • Stephen Davidson 216 posts 392 karma points
    Nov 23, 2012 @ 17:47
    Stephen Davidson
    0

    Moved this last question into its own post.

    S

Please Sign in or register to post replies

Write your reply to:

Draft