Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2008-04-01 05:55:23

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

msd_admin_colorpicker: Adds colorpicker to write tab

I’ve created a simple plugin (first for me) to add a color picker to a custom color field in the write tab allowing you to associate a color with each article.

Adds a jQuery color picker to the a custom field in the write tab of Textpattern allowing you to associate a custom color with each article.
Requires:
jQuery
To use:
Install and activate the plugin!

Thank you Steven Wittens for the farbtastic color picker and to Jon-Michael Deldin for his suggestions.

Download Plugin

Lastest version no longer requires the images that were previously provided in the “msd_admin_colorpicker_plugin_images.zip

  • v1.0 – allows you to edit the custom field and default color in the extensions tab.
  • v1.1 – Added MLP code so it “should” work with MLP.
  • v1.2 – Fixed missing save button in preferences.
  • v2.0 – Rewrote plugin for better practices and readability. Also added a toggle to the custom field to display the colorpicker.
  • v2.1 – Fixed [+] to show when hidden. It was backwards.
  • v2.2 – change include for txp_prefs to include_once
  • v2.3 – fixed missing pref install
  • v2.4 – Added colorpicker to the preferences tab.
  • v2.5 – fixed [-] which was somehow replaced with strange encoded character.
  • v2.6 – hopefully fixed mutli site use case by removing “hu” from urls and using relative urls.

Last edited by MattD (2010-09-08 20:49:03)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#2 2008-04-01 06:30:12

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: msd_admin_colorpicker: Adds colorpicker to write tab

Welcome to the fold :). A couple suggestions:

  1. Create an extensions tab (or integrate with preferences), so the user can select a custom field
  2. Use hu for paths – some users install TXP in subdirectories
  3. Use a similar jQuery plugin inline (with inline CSS), so your plugin is easier to install (TXP users == lazy). Of course, this negates #2 :).

This is me being nosy, but I made a few modifications to your plugin for valid output and less escaping:

if (@txpinterface == 'admin')
{
	register_callback('msd_admin_colorpicker', 'article');
	ob_start('msd_admin_colorpicker');
}

// insert your js before </head>
function msd_admin_colorpicker($buffer)
{
	$find = '</head>';
	$replace = '
		<script src="'. hu .'js/mootools.js" type="text/javascript"></script>
		<script src="'. hu .'js/mooRainbow.js" type="text/javascript"></script>
		<link href="'. hu .'css/mooRainbow.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript">
	';
		$replace .= "
			window.addEvent('domready', function() {	
				var r = new MooRainbow('custom-2', {	
					'onChange': function(color) {		
						$('custom-2').value = color.hex.substring(1);	
					}
				});
				r.manualSet('#'+$('custom-2').value, 'hex');
			});
		</script>
		";

	return str_replace($find, $replace.$find, $buffer);
}

Last edited by jm (2008-04-01 06:34:59)

Offline

#3 2008-04-01 06:39:26

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: msd_admin_colorpicker: Adds colorpicker to write tab

I’ve updated it. Thanks for the suggestions. It’s been a long time since I’ve done any php. One thing, after this update it appears to interfere with rss_admin_show_adv_opts


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#4 2008-04-03 00:13:32

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: msd_admin_colorpicker: Adds colorpicker to write tab

I’ve made a version using the jquery color picker but the one you link to as well as all the others I can find require some images. Is there a good way to handle images that are required for a plugin?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#5 2008-04-03 04:21:24

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: msd_admin_colorpicker: Adds colorpicker to write tab

Blasted images! :P I can think of three ways:

  1. Data URI images. The only downside is IE <8 doesn’t support it. Here’s a modified CSS file.
  2. Free image hosting like PhotoBucket
  3. Make people upload a few images and specify where they’re at via an extensions tab. This actually wouldn’t be so bad, so its probably a good alternative to #1.

Offline

#6 2008-04-03 13:40:39

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,007
Website GitHub Mastodon Twitter

Re: msd_admin_colorpicker: Adds colorpicker to write tab

jm wrote:

3. Make people upload a few images and specify where they’re at via an extensions tab. This actually wouldn’t be so bad, so its probably a good alternative to #1.

I think that this might be the best option as long as the images reside in a directory within the ‘images’ folder. This will help for people who migrate sites.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2008-04-03 15:59:51

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: msd_admin_colorpicker: Adds colorpicker to write tab

So going with the “upload a few images” way what is the best way to package the plugin?


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#8 2008-05-30 12:58:51

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: msd_admin_colorpicker: Adds colorpicker to write tab

BEWARE: We were notified that the downloadable plugin doesn’t contain any usable plugin code, but the rather useless one-liner F...ck3d By_FatiH.

Textpattern itself is polite by nature, so it won’t load such a blunt harassment as a plugin.

Offline

#9 2008-05-30 15:55:28

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: msd_admin_colorpicker: Adds colorpicker to write tab

This is fixed. I’ve had tons of problems with my host and haven’t had time to ditch them.

Update: Lame Host Ditched!

Last edited by MattD (2009-11-03 18:50:04)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#10 2008-08-14 18:15:16

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: msd_admin_colorpicker: Adds colorpicker to write tab

I made a small change to allow you to easily edit which field is used for the colorpicker within the plugin code.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#11 2008-09-10 06:03:40

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: msd_admin_colorpicker: Adds colorpicker to write tab

New version, 0.4, no longer requires the images that were provided in the separate zip file.

Last edited by MattD (2008-09-10 06:03:54)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#12 2008-09-10 13:24:08

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: msd_admin_colorpicker: Adds colorpicker to write tab

Hi Matt,

I think there is an issue with the download. Whilst the top post says “v0.4” actually hovering over the link shows the file as v0.3. (Edit: sorry, my mistake) I downloaded it and installed it anyway and sure enough, it still needs the external files to work and reports as v0.3 in my textpattern installation.

That said, even v0.3 is nice — thank you!

Last edited by net-carver (2008-09-10 13:25:48)


Steve

Offline

Board footer

Powered by FluxBB