var cs = ApplicationContext.Current.Services.ContentService;
var item = cs.GetById(1227);
item.SetValue("itemTags", "testTagName");
cs.SaveAndPublishWithStatus(item);
cs.RePublishAll();
umbraco.library.RefreshContent();
In another page i need to filter items by tag like this:
var filteredItemsByTag = Umbraco.TagQuery.GetContentByTag("testTagName");
But this method still does not return an item which was added above.
It works only if i "Save and Publish" current item from admin backoffice.
I see in Umbraco.Core that "GetContentByTag " method gets value from RuntimeCacheProvider, which has "Clear()" method, but class is internal, so i can't use it.
GetContentByTag method cache problem
Hi,
I tried to add tag to document programmatically:
In another page i need to filter items by tag like this:
But this method still does not return an item which was added above. It works only if i "Save and Publish" current item from admin backoffice.
I see in Umbraco.Core that "GetContentByTag " method gets value from RuntimeCacheProvider, which has "Clear()" method, but class is internal, so i can't use it.
Is there any way to get an item?
Thanks
Hi
I have the same problem. Works fine from backoffice but not when tags are added via API.
Hope for answer.
Hi!
Using IContent SetTags fixed my problem. This has been discussed in this post also: https://our.umbraco.org/forum/developers/api-questions/74836-setting-tags-on-images-via-icontentbase
Hope it helps!
is working on a reply...