SeoTopicEditTemplate
Editor for SeoTopics

02 May 2019 - 06:19 | Version 1

%{
}%
%TMPL:INCLUDE{"Applications.ClassificationApp.ClassifiedTopicEdit"}%
%{
}%

%{
}%
%TMPL:DEF{"validationrules"}% {'MetaDescription': {maxlength:160}} %TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"formfields"}%<!-- --> 
%TMPL:P{"categoriestab"}% 
%TMPL:P{"tagstab"}% 
%TMPL:P{"seotab"}% 
<!-- -->%TMPL:END%
%{
}%

%{
}%
%TMPL:DEF{"seotab"}%<!-- -->
%TAB{"%TRANSLATE{"SEO"}%"}%
---++ %TRANSLATE{"Search engine optimization"}%
%RENDERFOREDIT{"%BASEWEB%.%BASETOPIC%"
  form="%TMPL:P{"formdefinition"}%"
  fields="HTMLTitle, MetaKeywords, MetaDescription, MetaImage"
  HTMLTitle_title="%TRANSLATE{"HTML Title"}%"
  MetaKeywords_title="%TRANSLATE{"Meta keywords"}%"
  MetaDescription_title="%TRANSLATE{"Meta desciption"}%"
  MetaKeywords_default="%TAGINFO{topic="%BASEWEB%.%BASETOPIC%" format="$name"}%"
  MetaDescription_default="%FORMFIELD{"Summary" topic="%BASEWEB%.%BASETOPIC%"}%"
  MetaImage_title="%TRANSLATE{"Meta Image"}%"
}%
%ADDTOZONE{"script" 
   text="<script type='text/javascript' src='%PUBURLPATH%/Applications/ClassificationApp/SeoTopicEditTemplate/seo-topic-edit.js'></script>" 
   id="SEOTOPICEDIT::JS"
   requires="JQUERYPLUGIN"
}%%ENDTAB%
<!-- -->%TMPL:END%

%{
}%
"use strict";
jQuery(function($) {
  $(document).on("click", "#clsGenerateTitle", function() {
    $(this).parents(".foswikiFormStep:first").find("input").val($("input[name=TopicTitle]").val());
    return false;
  });

  $(document).on("click", "#clsGenerateDescription", function() {
    var $field = $(this).parents(".foswikiFormStep:first").find("textarea"),
        description = $("input[name=Summary]").val();

    if (!description) {
      description = $("#topic").val();
    }

    $field.val(description.replace(/<[^>]*>/g, "").replace(/\n\s*\n/g, "").substr(0, 160));
    return false;
  });

  $(document).on("click", "#clsGenerateKeywords", function() {
    var $field = $(this).parents(".foswikiFormStep:first").find("input"),
        keywords = [];

    $("input[name=Tag], input[name=Category]").each(function() {
      var vals = $.trim($(this).val()).split(/\s*,\s*/);
      $.each(vals, function(index, val) {
        val = val.replace(/Category$/, "");
        if (val) {
          keywords.push(val);
        }
      });
    });

    $field.val(keywords.join(", "));
    return false;
  });
});
%{
}%
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Flatiron Institute Documentation Center? Send feedback
This website is using cookies. More info. That's Fine