Overview of multiple ways of querying, filtering, and searching published content for use on your website.
Umbraco stores identifiers in UDI format for most Umbraco object types. This identifier stores all of the metadata required to retrieve an Umbraco object and is parse-able within text. Example: umb://document/4fed18d8c5e34d5e88cfff3a5b457bf2
. UDI's can be used in many of the querying APIs.
IPublishedContent
is strongly typed model for content, media and members that is used to render content in your views for your website.
UmbracoHelper is the unified way to work with published content/media on your website. Whether you are using MVC or WebForms you will be able to use UmbracoHelper to query/traverse Umbraco published data.
IMemberManager
is an user manager interface for accessing member data in the form of MemberIdentityUser
and converting it to IPublishedContent
.
The IPublishedContentQuery
interface contains query methods for accessing strongly typed content in services etc.
The ITagQuery
interface allows to work with tags in Umbraco.
The UmbracoContext is a simplified way to work with the current request on your website.
Working with tags in Umbraco
The ITagQuery
interface is your primary way to work with tags in Umbraco. This interface allows you to get different tags, such as content tags and media tags. It also lets you retrieve content by tag, for instance, getting all content nodes with the "Umbraco" tag.
If you're using it in Views or Partial views you can inject ITagQuery
using the @inject
keyword, for example
After this you can use _tagQuery
to access the ITagQuery
.
If you're using it in controllers, you can inject it into the constructor like so:
ITagQuery
is a scoped service, meaning that it should only be injected into scoped or transient services. For more information see the official Microsoft Documentation
All examples are from a view using the injection shown above, but working with tags in controllers will be the same.
Get a collection of tags used by content items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
Get a collection of tags used by media items on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
Get a collection of tags used by members on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
Get a collection of tags used on the site. Optionally, you can pass in a group name to only list tags belonging to a specific tag group
Get a collection of IPublishedContent by tag, and you can optionally filter by tag group as well
Get a collection of IPublishedContent by tag group
Get a collection of Media by tag, and you can optionally filter by tag group as well
Get a collection of Media by tag group
Get a collection of tags by entity id (queries content, media and members), and you can optionally filter by tag group as well
Get a collection of tags assigned to a property of an entity (queries content, media and members). Optionally, you can filter by tag group as well