<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><language>en</language><title>Blog posts by Russell Mercer</title> <link>https://world.optimizely.com/blogs/russell-mercer/</link><description></description><ttl>60</ttl><generator>Optimizely World</generator><item> <title>Using Adobe Typekit in EpiServer</title>            <link>https://world.optimizely.com/blogs/russell-mercer/dates/2017/7/using-adobe-typekit-in-episerver/</link>            <description>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Typekit provides embed code to load fonts&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://typekit.com/&quot;&gt;https://typekit.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The problem is that you want those same fonts to be present in the TinyMCE editor.&lt;/p&gt;
&lt;p&gt;I decided to use a TinyMCE plugin to load the TypeKit.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/link/617e0a5265a44c5e997820f4380dee78.aspx&quot;&gt;https://world.episerver.com/documentation/developer-guides/CMS/editing/Customizing-the-TinyMCE-editor/&lt;/a&gt;&amp;nbsp;-&amp;nbsp;Adding a TinyMCE plug-in&lt;/p&gt;
&lt;p&gt;I chose the option of creating a Util folder as per&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;/link/df61a51597354c7d8c3e61fc541848fe.aspx&quot;&gt;https://world.episerver.com/globalassets/sdkdocuments/developers-guide1/episerver-cms/75/editing/tinymce_add_javascript.png&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I only needed&amp;nbsp;editor_plugin.js under a folder that I named typekitplugin&lt;/p&gt;
&lt;p&gt;I created a class decorated with the TinyMCEPluginNonVisual attribute&lt;/p&gt;
&lt;p&gt;[TinyMCEPluginNonVisual(LanguagePath = &quot;/admin/tinymce/plugins/typekitplugin&quot;, PlugInName = &quot;typekitplugin&quot;)]&lt;br /&gt; public class TinyMCETypeKitPlugin&lt;br /&gt; {&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;Once that is done you need to activate it in the editor settings&lt;/p&gt;
&lt;p&gt;I.e. Admin - Config - Edit Custom Property Types -&amp;nbsp;XhtmlString &amp;gt; 255 - Plugins without a button&lt;/p&gt;
&lt;p&gt;You will find that it is missing a langauge entry&amp;nbsp;which you can fix by adding TinyMCE.xml under Resources/LanguageFiles&lt;/p&gt;
&lt;p&gt;=========================================&lt;/p&gt;
&lt;p&gt;&lt;span&gt;TinyMCE.xml&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;========================================&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&amp;gt;&lt;br /&gt;&amp;lt;languages&amp;gt;&lt;br /&gt; &amp;lt;language name=&quot;English&quot; id=&quot;en&quot;&amp;gt;&lt;br /&gt; &amp;lt;tinymce&amp;gt;&lt;br /&gt; &amp;lt;typekitplugin&amp;gt;&lt;br /&gt; &amp;lt;typekitplugin_desc&amp;gt;&lt;br /&gt; Typekit Plugin&lt;br /&gt; &amp;lt;/typekitplugin_desc&amp;gt;&lt;br /&gt; &amp;lt;/typekitplugin&amp;gt;&lt;br /&gt; &amp;lt;/tinymce&amp;gt;&lt;br /&gt; &amp;lt;/language&amp;gt;&lt;br /&gt;&amp;lt;/languages&amp;gt;&lt;/p&gt;
&lt;p&gt;=========================================&lt;/p&gt;
&lt;p&gt;&lt;span&gt;editor_plugin.js&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You will need to change &quot;xxxxxxx&quot; to the ID of the TypeKit&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Change the GetInfo function as appropriate&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;========================================&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;(function () {&lt;/p&gt;
&lt;p&gt;tinymce.create(&#39;tinymce.plugins.typekitplugin&#39;, {&lt;br /&gt; /**&lt;br /&gt; * Initializes the plugin, this will be executed after the plugin has been created.&lt;br /&gt; * This call is done before the editor instance has finished it&#39;s initialization so use the onInit event&lt;br /&gt; * of the editor instance to intercept that event.&lt;br /&gt; *&lt;br /&gt; * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.&lt;br /&gt; * @param {string} url Absolute URL to where the plugin is located.&lt;br /&gt; */&lt;br /&gt; init: function (ed, url) {&lt;br /&gt; ed.onPreInit.add(function (ed) {&lt;/p&gt;
&lt;p&gt;// Get the DOM document object for the IFRAME&lt;br /&gt; var doc = ed.getDoc();&lt;/p&gt;
&lt;p&gt;// Create the script we will add to the header asynchronously&lt;br /&gt; var jscript = &quot;(function() {\n\&lt;br /&gt; var config = {\n\&lt;br /&gt; kitId: &#39;&lt;span&gt;xxxxxxx&lt;/span&gt;&#39;\n\&lt;br /&gt; };\n\&lt;br /&gt; var d = false;\n\&lt;br /&gt; var tk = document.createElement(&#39;script&#39;);\n\&lt;br /&gt; tk.src = &#39;//use.typekit.net/&#39; + config.kitId + &#39;.js&#39;;\n\&lt;br /&gt; tk.type = &#39;text/javascript&#39;;\n\&lt;br /&gt; tk.async = &#39;true&#39;;\n\&lt;br /&gt; tk.onload = tk.onreadystatechange = function() {\n\&lt;br /&gt; var rs = this.readyState;\n\&lt;br /&gt; if (d || rs &amp;amp;&amp;amp; rs != &#39;complete&#39; &amp;amp;&amp;amp; rs != &#39;loaded&#39;) return;\n\&lt;br /&gt; d = true;\n\&lt;br /&gt; try { Typekit.load(config); } catch (e) {}\n\&lt;br /&gt; };\n\&lt;br /&gt; var s = document.getElementsByTagName(&#39;script&#39;)[0];\n\&lt;br /&gt; s.parentNode.insertBefore(tk, s);\n\&lt;br /&gt; })();&quot;;&lt;/p&gt;
&lt;p&gt;// Create a script element and insert the TypeKit code into it&lt;br /&gt; var script = doc.createElement(&quot;script&quot;);&lt;br /&gt; script.type = &quot;text/javascript&quot;;&lt;br /&gt; script.appendChild(doc.createTextNode(jscript));&lt;/p&gt;
&lt;p&gt;// Add the script to the header&lt;br /&gt; doc.getElementsByTagName(&#39;head&#39;)[0].appendChild(script);&lt;br /&gt; });&lt;br /&gt; },&lt;/p&gt;
&lt;p&gt;/**&lt;br /&gt; * Returns information about the plugin as a name/value array.&lt;br /&gt; * The current keys are longname, author, authorurl, infourl and version.&lt;br /&gt; *&lt;br /&gt; * @return {Object} Name/value array containing information about the plugin.&lt;br /&gt; */&lt;br /&gt; getInfo: function () {&lt;br /&gt; return {&lt;br /&gt; longname: &#39;TypeKit plugin for HaurikiPHO&#39;,&lt;br /&gt; author: &#39;Guru Digital&#39;,&lt;br /&gt; authorurl: &#39;http://gurudigital.nz&#39;,&lt;br /&gt; infourl: &#39;http://gurudigital.nz&#39;,&lt;br /&gt; version: &quot;1.0&quot;&lt;br /&gt; };&lt;br /&gt; }&lt;br /&gt; });&lt;/p&gt;
&lt;p&gt;// Register plugin&lt;br /&gt; tinymce.PluginManager.add(&#39;typekitplugin&#39;, tinymce.plugins.typekitplugin);&lt;br /&gt;})();&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</description>            <guid>https://world.optimizely.com/blogs/russell-mercer/dates/2017/7/using-adobe-typekit-in-episerver/</guid>            <pubDate>Mon, 31 Jul 2017 06:06:46 GMT</pubDate>           <category>Blog post</category></item><item> <title>CheckboxList using Enum</title>            <link>https://world.optimizely.com/blogs/russell-mercer/dates/2015/1/post-title/</link>            <description>I recently implemented a checkboxlist using Enum  &lt;br /&gt;References:  &lt;br /&gt;  &lt;ul&gt;   &lt;li&gt;http://joelabrahamsson.com/enum-properties-with-episerver/ &lt;/li&gt;   &lt;li&gt;http://world.episerver.com/blogs/Linus-Ekstrom/Dates/2013/12/SingleMultiple-selection-in-EPiServer-75/&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;My Code&lt;/p&gt;  &lt;pre&gt;

public class EnumMultipleSelectionFactory&amp;lt;TEnum&amp;gt; : ISelectionFactory
{
    public IEnumerable&amp;lt;ISelectItem&amp;gt; GetSelections(
            ExtendedMetadata metadata)
    {
        var values = Enum.GetValues(typeof(TEnum));
        List&amp;lt;ISelectItem&amp;gt; items = new List&amp;lt;ISelectItem&amp;gt;();
        foreach (var value in values)
        {
            items.Add(new SelectItem { Text = GetValueName(value), Value = value.ToString() });
        }
                return items;
    }

    private string GetValueName(object value)
    {
        var staticName = Enum.GetName(typeof(TEnum), value);

        string localizationPath = string.Format(
            &amp;quot;/property/enum/{0}/{1}&amp;quot;,
            typeof(TEnum).Name.ToLowerInvariant(),
            staticName.ToLowerInvariant());

        string localizedName;
        if (LocalizationService.Current.TryGetString(
            localizationPath,
            out localizedName))
        {
            return localizedName;
        }

        return staticName;
    }
}


public class EventItemPage : SitePageData
{
    public enum EventCategoryValues
    {
        Arts,
        Business,
        Community,
        Festivals,
        Kids,
        Recreation,
        Sports
    }

    [Display(
        GroupName = SystemTabNames.Content,
        Order = 1030)]
    [SelectMany(SelectionFactoryType = typeof(EnumMultipleSelectionFactory&amp;lt;EventCategoryValues&amp;gt;))]
    public virtual string EventCategories { get; set; }

}

&lt;/pre&gt;</description>            <guid>https://world.optimizely.com/blogs/russell-mercer/dates/2015/1/post-title/</guid>            <pubDate>Mon, 26 Jan 2015 23:12:43 GMT</pubDate>           <category>Blog post</category></item></channel>
</rss>