Creative Web Design & Development

MindPalette™ LLC is a creative web development company based in Indianapolis, IN. We are currently in a state of transition, and will be shifting most of our development focus to:

  • PHP Form Processing Scripts (new versions to replace NateMail and ProcessForm)
  • Joomla! Extensions (Components, Modules, Plug-ins & Templates)
  • WordPress Themes & Plugins
  • jQuery and JavaScript Plugins & Scripts

Though no longer actively developed, we will continue to offer free downloads of our GoLive Actions. The older Scripts and Tutorials are also still available, though future content and development will be in our new Development Blog.

PHP Broken Array from json_decode Object

I ran into an odd PHP thing (bug?) today. I had an object that had been extracted from a string using json_decode. After type-casting it to an array, any entries stored with numeric keys were inaccessible when calling by key, though iteration worked fine.

Here’s a simplified example:

// make an associative array
$myList = array(
	2=>'two',
	4=>'four',
	6=>'six',
	8=>'eight',
	'nine'=>'nine'
);
// json encode to string
$myList = json_encode($myList);
// json decode to object
$myList = json_decode($myList);
// typecast back to array
$myList = (array) $myList;
// test output
$test1 = (array_key_exists(4, $myList))
	? $myList[4] : 'nothing!';
$test2 = (array_key_exists('nine', $myList))
	? $myList['nine'] : 'nothing!';
echo 'test1: '.$test1.', test2: '.$test2;

Read More »

Get Field Label Text in Joomla 2.5 JForm

I’m switching back and forth between projects in Joomla 3.X and Joomla 2.5… to get the field label text (not the HTML tags, just the text) from a JFormField object is simple enough in Joomla 3.X, since the class has a getAttribute() method, so:

$field = $form->getField('myfield');
$label = $field->getAttribute('label');

I could be mistaken, but didn’t see the same functionality in Joomla 2.5. The closest I’ve come up with is to get the full label, then strip out the HTML tags, like:

$field = $form->getField('myfield');
$label = strip_tags($field->__get('label'));

…which is ugly, but seems to work in the cases I’ve tested. Anyone know of a better way to access the element attributes directly in Joomla 2.5?

ProcessForm 3.0.18 Security Update

We’ve just posted a security patch update to the old/archived script ProcessForm. It is strongly recommended that any existing users update to the latest version. We’re working hard on a complete re-write of the script, but in the meantime, will continue releasing patch updates as issues are found.

Advertisements: