Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi Everyone,
I am trying to query a group of tags from a razor view. I can see from various discussions that the suggested approach for this used to be:
@Umbraco.TagQuery.GetAllTags("SomeGroupName")
But "TagQuery" has been marked as obsolete in the V8 code and removed in the V9 code. It says:
"Inject and use an instance of ITagQuery in the constructor for using it in classes or get it from Current.TagQuery in views."
But how do I use "Current.TagQuery" in my razor view? Because "Current" is not a property on the UmbracoHelper. So I cant just do:
@Current.TagQuery.GetAllTags("SomeGroupName")
I have tried including:
@using Umbraco.Web.Composing
Because, this is where the "Current" class exists in the code. But I get an error:
"The type or namespace name 'Web' does not exist in the namespace 'Umbraco'"
Can anyone advise how this is supposed to work?
Thanks
Keith
Hi..
In views you can use the @inject keyword..
@using Umbraco.Cms.Core.PublishedCache; @inject ITagQuery TagQuery; ... @TagQuery.GetAllTags("SomeGroupName")
Wow! Thanks
Hi, have any one tried the GetContentByTag("Test", "Group1") ? Is there a known bug ?
I get 0 Content back, but I get all if I use the GetAllTags().
Im testing out Umbraco 9
EDIT: Found the issue, the tag name has to be lowercase to work.....
Hi, I am using Umbraco v8
I am trying to use ITagQuery in a partial view for building out a block view.
I tried to add the following : @inherits UmbracoViewPage
the first issue is: Cms does not exist in the namespace Umbraco the second issue is: The name 'inject' does not exist in the current context
What am I missing or doing wrong?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
TagQuery marked as Obsolete on UmbracoHelper, but how do you use the alternative?
Hi Everyone,
I am trying to query a group of tags from a razor view. I can see from various discussions that the suggested approach for this used to be:
But "TagQuery" has been marked as obsolete in the V8 code and removed in the V9 code. It says:
"Inject and use an instance of ITagQuery in the constructor for using it in classes or get it from Current.TagQuery in views."
But how do I use "Current.TagQuery" in my razor view? Because "Current" is not a property on the UmbracoHelper. So I cant just do:
I have tried including:
Because, this is where the "Current" class exists in the code. But I get an error:
"The type or namespace name 'Web' does not exist in the namespace 'Umbraco'"
Can anyone advise how this is supposed to work?
Thanks
Keith
Hi..
In views you can use the @inject keyword..
Wow! Thanks
Hi, have any one tried the GetContentByTag("Test", "Group1") ? Is there a known bug ?
I get 0 Content back, but I get all if I use the GetAllTags().
Im testing out Umbraco 9
EDIT: Found the issue, the tag name has to be lowercase to work.....
Hi, I am using Umbraco v8
I am trying to use ITagQuery in a partial view for building out a block view.
I tried to add the following : @inherits UmbracoViewPage
the first issue is: Cms does not exist in the namespace Umbraco the second issue is: The name 'inject' does not exist in the current context
What am I missing or doing wrong?
is working on a reply...