Пример #1
0
 private string RenderMobileMenus(List<DynamicMenuCurlyBracket> menus, TemplateRenderModel template)
 {
     if (menus.Any())
     {
         foreach (var dynamicMenuCurlyBracket in menus)
         {
             //Recursive render child html
             dynamicMenuCurlyBracket.ChildMenusString = RenderMobileMenus(dynamicMenuCurlyBracket.ChildMenus, _childMobileTemplate);
         }
         return _templateServices.Parse(template.Content, menus, null, template.CacheName);
     }
     return string.Empty;
 }
Пример #2
0
        /// <summary>
        /// Parse params from parameters
        /// </summary>
        /// <param name="parameters"></param>
        private void ParseParams(string[] parameters)
        {
            /*
             * Params:
             * * Parent Id
             * * Show Parent
             * * Parent Template
             * * Children Template
             */

            ParentTemplateName = DefaultTemplate;
            ChildTemplateName = DefaultChildTemplate;
            ChildMobileTemplateName = DefaultChildMobileTemplate;

            //ParentId
            if (parameters.Length > 1 && !string.IsNullOrEmpty(parameters[1]))
            {
                ParentId = parameters[1].ToNullableInt();
            }

            //ShowParentMenu
            if (parameters.Length > 2 && !string.IsNullOrEmpty(parameters[2]) && ParentId.HasValue)
            {
                ShowParentMenu = parameters[1].ToBool(false);
            }

            //ParentTemplateName
            if (parameters.Length > 3 && !string.IsNullOrEmpty(parameters[3]))
            {
                ParentTemplateName = parameters[3];
            }

            //ChildTemplateName
            if (parameters.Length > 4 && !string.IsNullOrEmpty(parameters[4]))
            {
                ChildTemplateName = parameters[4];
            }

            //ChildTemplateName
            if (parameters.Length > 5 && !string.IsNullOrEmpty(parameters[5]))
            {
                ChildMobileTemplateName = parameters[5];
            }

            _parentTemplate = _templateServices.GetTemplateByName(ParentTemplateName);
            if (_parentTemplate == null)
            {
                throw new Exception(string.Format("Template {0} is not founded.", ParentTemplateName));
            }
            _childTemplate = _templateServices.GetTemplateByName(ChildTemplateName);
            if (_childTemplate == null)
            {
                throw new Exception(string.Format("Template {0} is not founded.", ChildTemplateName));
            }
            _childMobileTemplate = _templateServices.GetTemplateByName(ChildMobileTemplateName);
            if (_childMobileTemplate == null)
            {
                throw new Exception(string.Format("Template {0} is not founded.", ChildMobileTemplateName));
            }
        }