About Alvin Reyes

Blogging, community-building, Tridion consultant.

Custom Url Coordinate Picker

In a previous post, I shared an SDL Tridion Custom Url Color Picker (pop-up) extension that read and set values from a single Component field.

This X & Y Coordinate Picker extends the concept to read and set values from multiple fields. Use these patterns in combination with your favorite JQuery or server-side controls to quickly create author-friendly interfaces for nearly any pop-up interface you could design. For other examples see:

Continue reading

SDL Tridion Custom Url Color Picker

I was preparing for my SDL Innovate workshop when I was reminded that Google updated its Maps API from version 2 to 3. We have a Custom Url example in the training environment based on a Google Maps GUI extension that use the older API.

While getting that to work, I thought a Custom Url example would be a nice touch to support one of my points on Contextual Experiences for Content Authors. Here’s a Color Picker extension based on Spectrum, “The No Hassle jQuery Colorpicker.”

Before using something like this, first read Robert Curlette’s views on a color selector and be sure you have the right use case, which might include:

  • Self-service configuration for a website, section, or templates where authors don’t set colors directly, but by choosing an option (that may have some color settings). Avoid using this at the component level if possible.
  • When templates or other semantic options won’t work (e.g. authors would have to choose from hundreds of color options out-of-context).
  • The color isn’t inline (otherwise rich text could work, though I’d recommend styles over inline colors)
  • Promotional content types–everything seems to go for promos, especially if they make money

Follow CMS “best practices” and avoid color selectors for well-structured content like articles or biographies.

Custom Url Markup

The pop-up’s markup just includes references and an input field:

ColorPicker.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<link rel="stylesheet" type="text/css" href="spectrum.css" />
	<link rel="stylesheet" type="text/css" href="ColorPicker.css" />

	<script type="text/javascript" src="docs/jquery-1.9.1.js"></script>
	<script type="text/javascript" language="javascript" src="/WebUI/Core/Controls/Popup/PopupInit.js"></script>
	<script type="text/javascript" language="javascript" src="spectrum.js"></script>
	<script type="text/javascript" language="javascript" src="ColorPicker.js"></script>
	<title>SDL Tridion ColorPicker</title>	
</head>

<body>
	<h2>Choose a color</h2>
		<div class="full">
			<input type="text" id="full"/>
			<p>Thanks to http://bgrins.github.com/spectrum for the color picker.</p>
		</div>
</body>
</html>
Powered by Spectrum Color Picker

Powered by Spectrum Color Picker

The CSS (ColorPicker.css) is simply a width setting.

.full-spectrum .sp-palette { max-width: 200px; }

Play with the options in this fiddle.

Tridion Setup

The Tridion-specific parts should be familiar to anyone who’s used Tridion’s Customer Url script and includes three parts:

  1. Field-parsing check using window.dialogArguments
  2. The “custom” JavaScript, in this case a nearly out-of-the-box Spectrum Color picker setup
  3. Wiring up the event handling parts for “choose” and “cancel.” The cancel link and choose button are added by the picker, so you won’t find these in the markup.

ColorPicker.js

// for SDL Tridion field and to store the color
var args =  window.dialogArguments;
var pickedcolor;

$(document).ready(function() {

// get and check field value
	if (args)
	{
		var fields = args.getFields();	
		if (fields && fields.length > 0)
		{
			var values = fields[0].getValues();
			if (values && values.length > 0)
			{
				pickedcolor = values[0];
			}
		}
	}

// see Spectrum jQuery Colorpicker documentation at:
// http://bgrins.github.io/spectrum/

$("#full").spectrum({
    color: pickedcolor,
	flat: true,showInput: true, className: "full-spectrum",
    showInitial: true, showPalette: true, showSelectionPalette: true,
    maxPaletteSize: 10, preferredFormat: "hex", localStorageKey: "spectrum.demo",
    move: function (color) { },
    show: function () {},
    beforeShow: function () {  },
    hide: function () { },
    change: function(c) {
	    var labelfull = $("#colorfull");
		color = c.toHexString();
        labelfull.text(c.toHexString());   		
    },
    palette: [
        ["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)",
        "rgb(204, 204, 204)", "rgb(217, 217, 217)","rgb(255, 255, 255)"],
        ["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
        "rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"], 
        ["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)", 
        "rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)", 
        "rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)", 
        "rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)", 
        "rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)", 
        "rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
        "rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
        "rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
        "rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)", 
        "rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
    ]
});

// listen for choose button -- no extra button needed
$(":button.sp-choose").click(function() {
		var args = window.dialogArguments;
		// set field value
		if (args) {
			//alert(" :button.sp-choose");
			var fields = args.getFields();
			if (fields && fields.length > 0) {
				fields[0].setValues([color]);
			}
		}	
		window.close();
});

// listen for cancel anchor -- no extra link needed
$("a.sp-cancel").click(function(e) {
	e.preventDefault();
	window.close();
});

});

Just be sure to include the above files along with the spectrum JavaScript and stylesheet. Then set a text field’s Custom Url to the HTML page (e.g. “/CustomUrls/ColorPicker/ColorPicker.html” for “%TRIDION_HOME%\web\CustomUrls\ColorPicker\ColorPicker.html“) and you’re, well, set. This could make nice compliment to your install of John Winter’s Image Map Extension.

Schema Setting

Custom Url

In this case, the problematic part isn’t Tridion, but potentially picking the color picker you prefer and configuring it correctly.

Learn more about Brian Grinstead’s Spectrum Color Picker.

SDL Tridion for Dummies Part 1 – an analytical start

In Bart Koopman’s previous post he asked if we wanted to take the SDL Tridion Template Quick Guides “one step further?” This answers that question with a first analytical step of the microsite in order to create a Web Content Model. This exercise is similar to creating a data model before a database or creating class diagrams before programming. Before setting up a CMS that lets us define how we manage pages and content, we first identify types of pages and their relationship to content and each other.

Two-Steps Analysis:

  1. Identify and describe page types
  2. Identify and describe content types

Caveat: to stay at the “Dummy” level, we pretend we have client and business requirements while assuming and skipping parts. For example, we are assuming the BluePrint is already set up. Easy!

This analysis will make sure you as the template developer and the client know what you’re building together. Frank M. Taylor explains why we really should gather CMS requirements:

Paceaux aka Frank M. Taylor has had scope blow up on him, like the Minecraft creepy he doesn't notice behind him.

“The scope can creep as much as it wants when you never establish it.”

Continue reading

SDL Content Porter’s Synchronization Option

An SDL Tridion schema is the (.xsd) definition for content. Eventually you may need to re-order, add, or remove fields to accommodate changes to your content model. Changing a schema doesn’t instantly change content based on this schema (trust me, you probably wouldn’t want it to). To make such an update, authors can open and close items in the Content Manager Explorer which will synchronize components to their updated definitions.

This works for a few dozen items, but can quickly get monotonous for several hundred components. Per SDL Live Content (http://sdllivecontent.sdl.com/), SDL Content Porter 2009 and later have the ability to “Synchronize Components against Schema before importing.”

“If you import a Component or a content item that has metadata, without also importing the (Metadata) Schema on which the item depends, the item you import may not match the Schema on the target system. Selecting this option tells Content Porter to attempt to modify the import item to match the Schema found on the target system.”

There’s a very important note that “selecting this option could lead to data loss.”

This synchronization option covers field re-ordering, removing fields no longer in the target schema(s), and adding new fields as long as they’re optional and/or have a default value. Also important is realizing this is a synchronization action which makes some existing fields match an updated schema. It should be clear that things like renaming fields and requiring a field without a default would require more manual (or programmatic) work.

The option is selected by default on an import, all you have to do is update the target schema before doing the import. Again, be careful with this as schema changes can lead to data loss.

Choose "Synchronize content against Schema before importing"

“Synchronize content against Schema before importing” is selected for you during imports


Continue reading

Where am I? Skinning the SDL Tridion Content Manager Explorer.

To provide context between similarly-looking SDL Tridion environments, consider Skinning the Content Manager Explorer as described on SDL Live Content.

Simplified, slightly modified, and with some pics. This is a fairly quick and easy way to make your CMS environments stand out from each other. For the full power of CME Themes, head on over to YATB.
Continue reading

Localization != Personalization. Why CXM Shouldn’t Affect Your SDL Tridion BluePrint… Much.

I’m seeing challenges and confusion with BluePrinting and Targeting in BluePrint workshops and in discussions about profiling and personalization. Don’t let the rise of “Customer Experience Management” (CXM or CEM for TLA fans) adversely affect your SDL Tridion BluePrint. Localization != Personalization (!= is code, literally, for “not equals”).

Continue reading

SDL Tridion Event System Newbie Perspective

SDL Tridion Principal Consultant, Mihai Cadariu outlined a use case for capturing user time stamp information and provided insight into approaches as well as sample code. I was able to replicate his setup and make my first (copy of someone else’s) event system. This type of setup might be old for you, but what impressed me compared to my R5.3 days was how easy it was to Google parts I wasn’t sure on.

Continue reading