Copied to clipboard

Flag this post as spam?

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


  • Prateek Sharma 1 post 21 karma points
    Aug 12, 2014 @ 13:27
    Prateek Sharma
    0

    How to Show All Authors Name

    When I use smart blog it always show only default author name my code is as follows

    @{
        // Get this blogs root, does not use an id because there may be more thanone blog
        dynamic blogRoot = CurrentPage.AncestorOrSelf("SmartBlogBlog");
        // Get the posts in this blog
        dynamic posts = blogRoot.Descendants("SmartBlogPost");
        //List of authors
        List<string> authors = new List<string>();
        System.Xml.XmlDocument document = new System.Xml.XmlDocument();
    
        document.Load(AppDomain.CurrentDomain.BaseDirectory + "/config/SmartBlog.config");
    
        // Loop through the posts to retrieve the authors and generate a list without duplicating them.
        foreach(dynamic post in posts)
        {
            string author = post.author.Length > 0 ? post.author.ToString() : document.GetElementsByTagName("defaultAuthor")[0].InnerText;
    
            if(!authors.Contains(author))
            {
                authors.Add(author);
            }
        }
    
        <span class="smartSubTitle smartTopBorder">Authors</span><br />
    
        // Loop through the generated authors list and add them tothe page
        foreach(string author in authors)
        {
            <a href="@Umbraco.NiceUrl(blogRoot.Id)?author=@author">@author</a><br />
        }
    }
    i always get default author name but i have many authors name in authors.please help me how can i solve this issue

     

  • Greg D'Abate 10 posts 56 karma points
    Sep 04, 2014 @ 23:01
    Greg D'Abate
    0

    If you go into the SmartBlog Management tab in the Content Section (Root node) and remove the Default Author, the authors entered at the post level will show.  With that said, I am having trouble with the Author List on the right side to update,

  • Greg D'Abate 10 posts 56 karma points
    Sep 05, 2014 @ 21:50
    Greg D'Abate
    0

    Spent the day trying to make the SmartListAuthors.cshtml work when there is no default author.  Below is the screenshot. There are authors, but not showing on the right-side list.  Code is out of the box, however is currently on localhost.  Any suggestions would be greatly appreciated.

  • Greg D'Abate 10 posts 56 karma points
    Sep 05, 2014 @ 23:24
    Greg D'Abate
    0

    FOUND IT!  Prateek Sharma In the SmartListAuthors.cshtml

    existing code:

    foreach(dynamicpostinposts)
       
    {
           
    stringauthor=post.author.Length>0?post.author.ToString():document.GetElementsByTagName("defaultAuthor")[0].InnerText;

           
    if(!authors.Contains(author))
           
    {
               
    authors.Add(author);
           
    }
       
    }
    Replace with:
    foreach(dynamic post in posts) { string author = post.smartBlogAuthor.Length > 0 ? post.smartBlogAuthor.ToString() : document.GetElementsByTagName("defaultAuthor")[0].InnerText; if(!authors.Contains(author)) { authors.Add(author); } }
Please Sign in or register to post replies

Write your reply to:

Draft