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?
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!
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 :)
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?
Is there no one that have had similar issues with "Remove at"?
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!
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?
I solved this by copying the method GetDocumentsWithTags from umbraco.cms.businesslogic.Tags.Tag and change the select query as follows:
This is definitely one of the strengths of open source projects :)
Thanks a lot for the pointers Tim!
No worries! Glad you managed to sort it!
:)
is working on a reply...