小辉网络社区致力于优质软件,活动线报,游戏辅助,绿色工具等资源共享,好货不私藏!

解决emlog6.0.0版不支持模板设置插件的问题

小辉工作室 EMLOG插件

emlog6.0.0正式版中使用官方模板设置时无法正常设置模板参数,下面的是教程详情:
第一步、首先找到路径/admin/views/template.php文件中代码:

<?php if (!defined('EMLOG_ROOT')) {exit('error!');}?>
后面加入代码:
<div id="containers"><?php doAction('adm_main_top'); ?>
第二步、找到代码替换模板设置插件(content/plugins/tpl_options/assets/main.js)的所有代码即可:
$(function() {
  //初始化变量
  var tplOptions = window.tplOptions;
  var body = $('body');
  var iframe = $('<iframe name="upload-image" src="about:blank" style="display:none"/>').appendTo(body);
  var optionArea = $('<div/>').appendTo($('#containers')).addClass(attr('area')).slideUp();
  var templateContent = $('.tpl:last, #container table');
  var loadingDom = $('<div />').appendTo(body);
  var message = $('<div />').appendTo($('.tpl_msg:first')).css('position', 'fixed');
  var timer, input, targetInput, target, templateInput, template;
  var trueInput = $('<input type="file" name="image">').css({
    position: 'absolute',
    margin: 0,
    visibility: 'hidden'
  }).on('change', function() {
    loading();
    target = input.data('target');
    targetInput.val(target);
    templateInput.val(template);
    form.submit();
  }).on('mouseleave', function() {
    trueInput.css('visibility', 'hidden');
    input.css('visibility', 'visible');
  });
  var form = $('<form id="upload-form" target="upload-image" />').append(
    trueInput,
    targetInput = $('<input type="hidden" name="target">'),
    templateInput = $('<input type="hidden" name="template">')
    ).appendTo(body).attr({
      action: tplOptions.uploadUrl,
      target: 'upload-image',
      enctype: 'multipart/form-data',
      method: 'post'
    });
  //插入设置按钮
  for (var tpl in tplOptions.templates) {
    (function(tpl) {
      var td = $('.active .act').parent();
      $('<span>设置  </span>').insertBefore(td.find('a')).addClass(attr('setting')).data('template', tpl);
    })(tpl);
  }
  //当前模板
  (function() {
    try 
    {
      var c
      urrentTemplate = $('.theme_ntpls .theme-preview .screenshot img').attr('src').match(/\/templates\/(.*?)\/preview.jpg/)[1];
      if (tplOptions.templates[currentTemplate]) {
        $('<br>').insertBefore($('<span><strong>[设置]</strong></span>').appendTo($('.theme_ntpls .theme-info')).addClass(attr('setting')).data('template', currentTemplate));
      }
    }catch(err) {}
  })();
  //绑定事件
  body.on('click', '.' + attr('setting'), function() {
    $.ajax({
      url: tplOptions.baseUrl,
      data: {
        template: $(this).data('template')
      },
      cache: false,
      beforeSend: function() {
        loading();
        editorMap = {};
      },
      success: function(data) {
        templateContent.slideUp(500, function() {
          optionArea.html(data).slideDown();
          window.setTimeout(function() {
            initOptionSort();
            initRichText();
            loading(false);
          }, 0);
        });
      }
    });
  }).on('click', '.tpl-options-close', function() {
    optionArea.slideUp(500, function() {
      templateContent.slideDown();
    });
  }).on('click', '.option-sort-name', function() {
    var that = $(this);
    if (that.is('.selected')) {
      return;
    }
    var left = that.parent(),
    right = left.siblings('.option-sort-right');
    left.find('.selected').removeClass('selected');
    that.addClass('selected');
    right.find('.option-sort-option').removeClass('selected').eq(that.index()).addClass('selected');
  }).on('change', '.option-sort-select', function() {
    var that = $(this);
    var right = that.parent().siblings('.option-sort-right');
    right.find('.option-sort-option').removeClass('selected').eq(that.find('option:selected').index()).addClass('selected');
  }).on('mouseenter', '.tpl-options-form input[type="file"]', function() {
    input = $(this);
    trueInput.css(input.offset());
    input.css('visibility', 'hidden');
    trueInput.css('visibility', 'visible');
  }).on('submit', 'form.tpl-options-form', function() {
    var that = $(this);
    $.ajax({
      url: that.attr('action'),
      type: 'post',
      data: that.serialize(),
      cache: false,
      dataType: 'json',
      // beforeSend: loading,
      success: function(data) {
        showMsg(data.code, data.msg);
      },
      error: function() {
        showMsg(1, '网络异常');
      },
      complete: function() {
        // loading(false);
      }
    });
    return false;
  }).on('change', '.tpl-options-form input, .tpl-options-form textarea', function() {
    $('form.tpl-options-form').trigger('submit');
  });
  //定义方法
  var initRichText = (function() {
    var num = 0;
    return function() {
      $('.option-rich-text').each(function() {
        var that = $(this);
        if (that.attr('id') === undefined) {
          that.attr('id', 'option-rich-text-' + (num++));
        }
        loadEditor(that.attr('id'));
      });
      window.setTimeout(function() {
        for (var id in editorMap) {
          editorMap[id].container[0].style.width = '';
        }
      }, 100);
    }
  })();
  window.setImage = function(src, path, code, msg) {
    if (code == 0) {
      $('[name="' + target + '"]').val(path).trigger('change');
      $('[data-name="' + target + '"]').attr('href', src).find('img').attr('src', src);
    } else {
      alert('上传失败:' + msg)
    }
    trueInput.val('');
    target = '';
    loading(false);
  };
 
  function initOptionSort() {
    $('.option-sort-left').each(function() {
      $(this).find('.option-sort-name:first').addClass('selected');
    });
    $('.option-sort-right').each(function() {
      $(this).find('.option-sort-option:first').addClass('selected');
    });
  }
 
  function loading(enable) {
    if (enable === undefined) {
      enable = true;
    }
    if (enable) {
      loadingDom.addClass('loading');
    } else {
      loadingDom.removeClass('loading');
    }
  }
 
  function showMsg(code, msg) {
    message.text(msg).css('display', '');
    if (code == 0) {
      message.attr('class', 'alert alert-info alert-tpl');
      if (timer) {
        window.clearTimeout(timer);
      }
      timer = window.setTimeout(function() {
        message.hide();
      }, 2600);
    } else {
      message.attr('class', 'alert alert-danger alert-tpl');
    }
  }
 
  function attr(name) {
    return tplOptions.prefix + name;
  }
 
  function loadEditor(id) {
    editorMap[id] = editorMap[id] || KindEditor.create('#' + id, {
      resizeMode: 1,
      allowUpload: false,
      allowImageUpload: false,
      allowFlashUpload: false,
      allowPreviewEmoticons: false,
      filterMode: false,
      afterChange: (function() {
        var t, i = 0;
        return function() {
          var that = this;
          if (t) {
            window.clearTimeout(t);
          }
          if (i++ > 0) {
            t = window.setTimeout(function() {
              that.sync();
              $(that.srcElement[0]).trigger('change');
            }, 2000);
          }
        }
      })(),
      urlType: 'domain',
      items: ['bold', 'italic', 'underline', 'strikethrough', 'forecolor', 'hilitecolor', 'fontname', 'fontsize', 'lineheight', 'removeformat', 'plainpaste', 'quickformat', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'image', 'flash', 'table', 'emoticons', 'code', 'fullscreen', 'source', '|', 'about']
    });
  }
});
温馨提示:本教程只针对emlog6.0.0版本,其他emlog版无效!教程有小问题,不管模板支持不支持模板设置,都会显示设置2字。

温馨提示:如有转载或引用以上内容请将本文链接作为出处标注!百度已收录

免责声明:本站提供的一切软件、教程和内容信息仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序,请支持正版,购买注册,得到更好的正版服务。侵删请致信E-mail:431228450@qq.com

标签 暂无标签
资源分享
评论列表