Copied to clipboard

Flag this post as spam?

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


  • Niklas Jalmerud 26 posts 62 karma points
    Nov 01, 2011 @ 11:12
    Niklas Jalmerud
    0

    Problem with getContentsWithTags in combination with "Remove at"

    Hi.

    I try to use the BlogpostRelatedPages.xslt in the Blog4Umbraco package. In that file they use the function getContentsWithTags and it works fine as long as I have no document that gets umpublished by "Remove at". If I do that it crashes because it tries to get that document but wont get any value from the query: 

    "select xml from cmsContentXml where nodeID = 3208"

    Why isn't nodes with "Remove at" treated the same as "Unpublished" ones? Is there a workaround for this?

     

  • Niklas Jalmerud 26 posts 62 karma points
    Nov 07, 2011 @ 09:05
    Niklas Jalmerud
    0

    Is there no one that have had similar issues with "Remove at"?

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Nov 07, 2011 @ 12:01
    Tim
    0

    There are some issues with the logic on some of the tags methods, if memory serves me correctly they don't always check if everything is unpublished or not. Are you using the old version of Blog4Umbraco, or the latest one that Ben Howarths been working on?

    You could always grab the source for the tags methods and roll out your own XSLT extensions to work with the content if you need to sort this urgently!

  • Niklas Jalmerud 26 posts 62 karma points
    Nov 07, 2011 @ 14:39
    Niklas Jalmerud
    0

    The version of Blog4Umbraco I have now is 2.0.26 and it seems to be the same version here : http://blog4umbraco.codeplex.com/

     

    The tags methods you are talking about is the ones found in Umbraco sourcecode right? 

     
  • Niklas Jalmerud 26 posts 62 karma points
    Nov 08, 2011 @ 09:32
    Niklas Jalmerud
    0

    I solved this by copying the method GetDocumentsWithTags from umbraco.cms.businesslogic.Tags.Tag and change the select query as follows:

    public static IEnumerable GetDocumentsWithTags(string tags)
            {
    
                var docs = new List();
                string sql = @"SELECT DISTINCT cmsTagRelationShip.nodeid from cmsTagRelationShip
                                INNER JOIN cmsTags ON cmsTagRelationShip.tagid = cmsTags.id 
                                INNER JOIN umbracoNode ON cmsTagRelationShip.nodeId = umbracoNode.id
                                INNER JOIN cmsDocument ON cmsTagRelationShip.nodeId = cmsDocument.nodeID                        
                                WHERE (cmsTags.tag IN ({0})) AND nodeObjectType=@nodeType
                                AND cmsDocument.published = 1 AND (cmsDocument.expireDate > @currentDate OR cmsDocument.expireDate is null)";
    
                using (IRecordsReader rr = SqlHelper.ExecuteReader(string.Format(sql, GetSqlStringArray(tags)),
                    SqlHelper.CreateParameter("@nodeType", Document._objectType), SqlHelper.CreateParameter("@currentDate", DateTime.Now)))
                {
                    while (rr.Read())
                    {
                        Document cnode = new Document(rr.GetInt("nodeid"));
    
                        if (cnode != null && cnode.Published)
                            docs.Add(cnode);
                    }
                }
    
                return docs;
            }

    This is definitely one of the strengths of open source projects :)

     

    Thanks a lot for the pointers Tim!

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Nov 08, 2011 @ 10:37
    Tim
    0

    No worries! Glad you managed to sort it!

    :)

Please Sign in or register to post replies

Write your reply to:

Draft