﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mark van Aalst &#187; Custom field</title>
	<atom:link href="http://www.markvanaalst.net/category/custom-field/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markvanaalst.net</link>
	<description>blogging about ASP.Net and web development related techniques</description>
	<lastBuildDate>Thu, 18 Feb 2010 18:12:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Using JQuery in custom fields</title>
		<link>http://www.markvanaalst.net/2010/02/18/using-jquery-in-custom-fields/</link>
		<comments>http://www.markvanaalst.net/2010/02/18/using-jquery-in-custom-fields/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 17:27:38 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Custom field]]></category>
		<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.markvanaalst.net/?p=99</guid>
		<description><![CDATA[At the moment I&#8217;m creating a custom field for tagging content items. I prototyped my custom field in html using JQuery. But when I wanted to convert this to the actual custom field I ran into a problem. As you might know Sitecore uses the Prototype library for all of it&#8217;s javascript. And prototype uses [...]]]></description>
			<content:encoded><![CDATA[<p>At the moment I&#8217;m creating a custom field for tagging content items. I prototyped my custom field in html using JQuery. But when I wanted to convert this to the actual custom field I ran into a problem. As you might know Sitecore uses the Prototype library for all of it&#8217;s javascript. And prototype uses the same dollar sign for all of its functions and variables as JQuery does. But JQuery provides a <a href="http://api.jquery.com/jQuery.noConflict/">noConflict</a> function where you can reassign the default $.</p>
<p>But then came the next challenge. I needed to use the noConflict function before all other javascript was called. Luckally I remembered that I have seen it before in other custom fields that are on the <a href="http://trac.sitecore.net/Index/">Shared Source</a> environment. So I started browsing the source code of Alexey Rusakov&#8217;s project (<a href="http://trac.sitecore.net/FieldTypes/">Sitecore Fieldtypes</a>) and I found the <a href="http://svn.sitecore.net/FieldTypes/trunk/sitecore%20modules/Outercore.FieldTypes/Common/InjectScripts.cs">InjectScripts</a> class which provides an option to add HTML to the section of the Content Editor. There I just added a reference to my JQuery library and off course calling the .noConflict funtion.</p>
<pre class="brush: csharp">

namespace Sitecore.SharedSource.Taxonomy
{
class AddScripts
{
public void Process(PipelineArgs args)
{
if (Sitecore.Context.ClientPage.IsEvent)
return;

HttpContext context = HttpContext.Current;
if (context == null)
return;

Page page = context.Handler as Page;
if (page == null)
return;

Assert.IsNotNull(page.Header, &quot;Content Editor &lt;head&gt; tag is missing runat=&#039;value&#039;&quot;);

string[] scripts = new[]
{
&quot;/sitecore modules/Shell/Taxonomy/jquery-1.4.1.min.js&quot;
};

foreach (string script in scripts)
{
page.Header.Controls.Add(new LiteralControl(&quot;&lt;script type=&#039;text/javascript&#039; language=&#039;javascript&#039; src=&#039;{0}&#039;&gt;&lt;/script&gt;&quot;.FormatWith(script)));
page.Header.Controls.Add(new LiteralControl(&quot;&lt;script type=\&quot;text/javascript\&quot;&gt;$.noConflict();&lt;/script&gt;&quot;));
}
}

}
}
</pre>
<p>So now I can call my JQuery by using &#8220;jQuery&#8221; in stead of &#8220;$&#8221; and the field works.</p>
<p>In my opinion this is just an example of how the Shared Source environment can help you. So if you have created a module, field or any thing else please put it on the Shared Source environment so others can benefit from it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markvanaalst.net/2010/02/18/using-jquery-in-custom-fields/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Embedding video in Sitecore items</title>
		<link>http://www.markvanaalst.net/2009/08/07/embedding-video-in-sitecore-items/</link>
		<comments>http://www.markvanaalst.net/2009/08/07/embedding-video-in-sitecore-items/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 12:26:33 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Custom field]]></category>
		<category><![CDATA[Sitecore]]></category>
		<category><![CDATA[User Interface]]></category>
		<category><![CDATA[controls]]></category>
		<category><![CDATA[Sitecore 6]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.markvanaalst.net/?p=34</guid>
		<description><![CDATA[These days streaming video on the web is quite popular. In almost every project we do at Evident Interactive the customer wants to embed video in content items. Off course they can do that by copy-pasting the embedding code in a Sitecore field or in the rich-text editor. But that is not the most user-friendly [...]]]></description>
			<content:encoded><![CDATA[<p>These days streaming video on the web is quite popular. In almost every project we do at <a href="http://www.evident.nl" target="_blank">Evident Interactive</a> the customer wants to embed video in content items. Off course they can do that by copy-pasting the embedding code in a Sitecore field or in the rich-text editor. But that is not the most user-friendly method. I thought it would be nice if an end-user could just copy-paste the url of the page and let an custom control do the rest. So I created a custom field, webcontrol, some xsl extensions an a addition to the flashmanager. Let&#8217;s say that we want to embed this <a href="http://www.youtube.com/watch?v=MKPmrwGuEkQ" target="_blank">video</a> from YouTube. I go to the content editor and paste the url in a field of the type &#8220;Video Embed&#8221;.</p>
<p><img class="size-full wp-image-36" title="Custom field" src="http://www.markvanaalst.net/files/2009/08/video_field.jpg" alt="Custom field" width="393" height="63" /><br />
<span id="more-34"></span> When I want to double check if I pasted the correct url I can click preview. A popup appears with the embedded video.</p>
<p><img class="alignnone size-full wp-image-38" title="Preview" src="http://www.markvanaalst.net/files/2009/08/video_preview.jpg" alt="Preview" width="442" height="329" /></p>
<p>Then I can save my item and publish it to the web database. The only thing saved in Sitecore is the url to the page containing the video.</p>
<p>But sometimes you want to embed video in to an rich text field. For this I wrote an extension for the flashmanager. It works the same as the custom field, the only thing different is you get a preview inside the tab and the embed code will be copied to to rich-text editor value.</p>
<p><img class="alignnone size-full wp-image-37" title="video_flashmanager" src="http://www.markvanaalst.net/files/2009/08/video_flashmanager.jpg" alt="video_flashmanager" width="441" height="311" /></p>
<p>To show my video in the frontend of the site I need to add an custom control to my layout or sublayout. The custom control is included in the package.</p>
<p>You need to add a page directive to your layout or sublayout</p>
<pre class="brush: csharp">
&lt;%@ Register TagPrefix=&quot;video&quot; Namespace=&quot;Sitecore.SharedSource.VideoEmbed&quot; Assembly=&quot;VideoEmbed&quot; %&gt;
</pre>
<p>Then you can add the custom control. You can set the height and width of the embed code. When those are left blank a default size of 240 for the height and 320 for the width will be used.</p>
<pre class="brush: csharp">
&lt;video:EmbedVideo id=&quot;VideoEmbed1&quot; runat=&quot;server&quot; Field=&quot;Video&quot; Height=&quot;240&quot; Width=&quot;320&quot;&gt;&lt;/video:EmbedVideo&gt;
</pre>
<p>And here is the result of the control</p>
<p><img class="alignnone size-full wp-image-44" title="Frontend" src="http://www.markvanaalst.net/files/2009/08/video_frontend.jpg" alt="Frontend" width="419" height="500" /></p>
<p>At the moment the solution works for YouTube, Vimeo and Google Video (international and dutch version). I will contribute this to the Shared Source section of Sitecore as soon as <a href="http://sharesitecore.wordpress.com/" target="_blank">Jimmie</a> is back from holiday and can give me access.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markvanaalst.net/2009/08/07/embedding-video-in-sitecore-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
