Example #1
0
        public string RendHtml()
        {
            StringBuilder stringBuilder = new StringBuilder();
            XmlNode       xmlNode       = TagsHelper.FindCommentNode(this.CommentId, "attribute");

            if (xmlNode != null)
            {
                stringBuilder.AppendFormat("<div class=\"attribute_bd cssEdite\" type=\"attribute\" id=\"comments_{0}\" >", this.CommentId).AppendLine();
                int categoryId = 0;
                int num        = 0;
                int.TryParse(xmlNode.Attributes["CategoryId"].Value, out categoryId);
                int.TryParse(xmlNode.Attributes["MaxNum"].Value, out num);
                string       text     = null;
                CategoryInfo category = CatalogHelper.GetCategory(categoryId);
                if (category != null)
                {
                    text = category.RewriteName;
                }
                IList <AttributeInfo> attributeInfoByCategoryId = ProductTypeHelper.GetAttributeInfoByCategoryId(categoryId, 1000);
                string text2 = (!string.IsNullOrWhiteSpace(text)) ? base.GetRouteUrl("subCategory_Rewrite", new
                {
                    rewrite    = text,
                    categoryId = categoryId
                }) : base.GetRouteUrl("subCategory", new
                {
                    categoryId
                });
                if (attributeInfoByCategoryId != null && attributeInfoByCategoryId.Count > 0)
                {
                    foreach (AttributeInfo item in attributeInfoByCategoryId)
                    {
                        stringBuilder.AppendLine("<dl class=\"attribute_dl\">");
                        stringBuilder.AppendFormat("<dt class=\"attribute_name\">{0}:</dt>", item.AttributeName).AppendLine();
                        stringBuilder.AppendLine("<dd class=\"attribute_val\">");
                        stringBuilder.AppendLine("<div class=\"h_chooselist\">");
                        foreach (AttributeValueInfo attributeValue in item.AttributeValues)
                        {
                            stringBuilder.AppendFormat("<a href=\"{0}\" >{1}</a>", text2 + "?valueStr=" + attributeValue.AttributeId + "_" + attributeValue.ValueId, attributeValue.ValueStr).AppendLine();
                        }
                        stringBuilder.AppendLine("</div>");
                        stringBuilder.AppendLine("</dd>");
                        stringBuilder.AppendLine("</dl>");
                    }
                }
                stringBuilder.AppendLine("</div>");
            }
            return(stringBuilder.ToString());
        }
Example #2
0
        private void RendeAttribute(StringBuilder sb)
        {
            IList <AttributeInfo> attributeInfoByCategoryId = ProductTypeHelper.GetAttributeInfoByCategoryId(this.categoryId, 1000);

            if (attributeInfoByCategoryId != null && attributeInfoByCategoryId.Count > 0)
            {
                foreach (AttributeInfo item in attributeInfoByCategoryId)
                {
                    sb.AppendLine("<dl class=\"attribute_dl\">");
                    if (item.AttributeValues.Count > 0)
                    {
                        sb.AppendFormat("<dt class=\"attribute_name\">{0}:</dt>", item.AttributeName).AppendLine();
                        sb.AppendLine("<dd class=\"attribute_val\">");
                        sb.AppendLine("<div class=\"h_chooselist\">");
                        string text      = "all";
                        string paraValue = this.RemoveAttribute(this.valueStr, item.AttributeId, 0);
                        string arg       = "all select";
                        if (!string.IsNullOrEmpty(this.valueStr) && new Regex($"{item.AttributeId}_[1-9]+").IsMatch(this.valueStr))
                        {
                            arg = "all";
                        }
                        sb.AppendFormat("<a class=\"{0}\" href=\"{1}\" >全部</a>", arg, this.CreateUrl("valuestr", paraValue)).AppendLine();
                        foreach (AttributeValueInfo attributeValue in item.AttributeValues)
                        {
                            text      = string.Empty;
                            paraValue = this.RemoveAttribute(this.valueStr, item.AttributeId, attributeValue.ValueId);
                            if (!string.IsNullOrEmpty(this.valueStr))
                            {
                                string[] source = this.valueStr.Split('-');
                                if (source.Contains(item.AttributeId + "_" + attributeValue.ValueId))
                                {
                                    text = "select";
                                }
                            }
                            sb.AppendFormat("<a class=\"{0}\" href=\"{1}\" >{2}</a>", text, this.CreateUrl("valuestr", paraValue), attributeValue.ValueStr).AppendLine();
                        }
                        sb.AppendLine("</div>");
                        sb.AppendLine("</dd>");
                    }
                    sb.AppendLine("</dl>");
                }
            }
        }