Esempio n. 1
0
        /// <summary>
        /// Returns all content that is tagged with the specified tag value and optional tag group
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="tagGroup"></param>
        /// <returns></returns>
        public IEnumerable <IPublishedContent> GetContentByTag(string tag, string tagGroup = null)
        {
            //TODO: http://issues.umbraco.org/issue/U4-6899
            if (_wrappedQuery != null)
            {
                return(_wrappedQuery.GetContentByTag(tag, tagGroup));
            }

            var ids = _tagService.GetTaggedContentByTag(tag, tagGroup)
                      .Select(x => x.EntityId);

            return(_typedContentQuery.TypedContent(ids)
                   .Where(x => x != null));
        }
Esempio n. 2
0
        public ActionResult GetContentByTags(string[] tags)
        {
            if (tags != null)
            {
                List <string> tagItems = new List <string>();
                foreach (var item in tags)
                {
                    tagItems.AddRange(_tagService.GetContentByTag(item).Select(x => x.Name).ToList());
                }


                return(Json(tagItems, JsonRequestBehavior.AllowGet));;
            }
            return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
        }