Posted on Leave a comment

jQuery roadblock

jQuery problem:

<table>
<tr><td>one</td><td>two</td><td>three</td><td><a class=”foo” href=””>click me first</a></td></tr>
<tr><td>one</td><td>two</td><td>three</td><td><a class=”bar” href=””>click me second</a></td></tr>
</table>

What jQuery would allow me to click on "click me second" and change the color of the text "click me first"?

It’s a little more complicated than that. The real source has a plus image on the first row. Once you click that I use .hide() to make the plus go away. I create the 2nd row which has a minus image and a plus image. If you click the plus image, it disappears and creates a third row. The minus image, should 1st) cause the immediate plus image above it to appear 2) then disappear its own row. All plus images have a class of "addrow" and minus images have a class of "deleterow" I thought prev() would be doing it but I get nothing. Specifically .prev(‘.addrow’).show();

Posted on Leave a comment

Magento – Not currently favorite color

Why is debugging and troubleshooting in Magento so difficult? Because of error messages like this:

Notice: Undefined variable: rootNode in C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Eav\Model\Entity\Attribute\Source\Config.php on line 53
Trace:
#0 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Eav\Model\Entity\Attribute\Source\Config.php(53): mageCoreErrorHandler(8, ‘Undefined varia…’, ‘C:\Domains\exam…’, 53, Array)
#1 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Adminhtml\Block\Widget\Form.php(196): Mage_Eav_Model_Entity_Attribute_Source_Config->getAllOptions(true, true)
#2 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tab\Account.php(54): Mage_Adminhtml_Block_Widget_Form->_setFieldset(Array, Object(Varien_Data_Form_Element_Fieldset))
#3 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Adminhtml\Block\Customer\Edit\Tabs.php(58): Mage_Adminhtml_Block_Customer_Edit_Tab_Account->initForm()
#4 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Abstract.php(642): Mage_Adminhtml_Block_Customer_Edit_Tabs->_beforeToHtml()
#5 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Text\List.php(43): Mage_Core_Block_Abstract->toHtml()
#6 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Abstract.php(643): Mage_Core_Block_Text_List->_toHtml()
#7 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Abstract.php(503): Mage_Core_Block_Abstract->toHtml()
#8 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Abstract.php(454): Mage_Core_Block_Abstract->_getChildHtml(‘left’, true)
#9 C:\Domains\example.com\wwwroot\magento\app\design\adminhtml\default\default\template\page.phtml(58): Mage_Core_Block_Abstract->getChildHtml(‘left’)
#10 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Template.php(144): include(‘C:\Domains\leoa…’)
#11 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Template.php(176): Mage_Core_Block_Template->fetchView(‘adminhtml\defau…’)
#12 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Template.php(193): Mage_Core_Block_Template->renderView()
#13 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Adminhtml\Block\Template.php(81): Mage_Core_Block_Template->_toHtml()
#14 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Block\Abstract.php(643): Mage_Adminhtml_Block_Template->_toHtml()
#15 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Model\Layout.php(526): Mage_Core_Block_Abstract->toHtml()
#16 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Controller\Varien\Action.php(347): Mage_Core_Model_Layout->getOutput()
#17 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Adminhtml\controllers\CustomerController.php(117): Mage_Core_Controller_Varien_Action->renderLayout()
#18 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Controller\Varien\Action.php(376): Mage_Adminhtml_CustomerController->editAction()
#19 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(‘edit’)
#20 C:\Domains\example.com\wwwroot\magento\app\code\core\Mage\Core\Controller\Varien\Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#21 C:\Domains\example.com\wwwroot\magento\app\Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#22 C:\Domains\example.com\wwwroot\magento\index.php(65): Mage::run()
#23 {main}

Yes, it screams "undefined variable" which is rootNode but through Magento’s excellent use of object oriented spaghetti, the error does not in anyway reveal what is truly causing rootNode to be undefined nor where to even begin looking.

Posted on Leave a comment

Current Magento Questions – getCustomerFormData

The Magento ecommerce question I am trying to answer right now is what does getCustomerFormData() do?

In AccountController.php and Register.php there is this reference $data = $this->_getSession()->getCustomerFormData(true); and this reference $data = new Varien_Object(Mage::getSingleton(‘customer/session’)->getCustomerFormData(true)); respectively. I’ve searched using grep and within eclipse’s file search but can find no other reference to getCustomerFormData.

I can find no reference to getCustomerFormData other than these two lines of code. So what is this supposed to be accomplishing?

Posted on 1 Comment

Magento – Developer Killer

While trying to add some functionality to my client’s Magento ecommerce store, I came across an article that summed up my Magento experience quite well:

Most of us in ecommerce application development have already heard of Magento. Some would call it new ecommerce killer app. I myself stand with that statement for many of reasons. However I would like to call it with one more name, developer killer app. This developer killer is what I literally had in mind. Magento is currently one of the most difficult PHP systems out there a developer could learn and master. [Source, {}activecodeline, What makes Magento so hard to learn (emphasis added)]

I have put so much effort into learning this system that I both never want to touch it again AND must do more Magento development so that this exercise of gaining knowledge does not go to waste.

Today’s links for Magento success:

Posted on Leave a comment

Magento References

Relevant to my life right now:

Posted on 2 Comments

Magento Actions

The Magento E-commerce system is an exciting open source alternative to systems like OS Commerce. The learning curve isn’t really a curve at all. The learning curve is more like a sheer, glassy. polished mountain face shooting straight up into the heavens. However, plenty of documentation exists, Google overfloweth with links to blog post, and IRC support is available on Freenode #magento (although I believe most questions go to /dev/null so expect to feel a little like you are talking to yourself but like your $200/hr psychologist will explain, sometimes that’s all we need).

As I work through understanding how Magento handles layouts, I struggle to find a simple list of actions and perhaps I’m trying to hard. So far the is this:

addJs
addCss
addLink
addItemRender
unsetChild
setHeaderTitle
setTemplate

Ah! I found a reference! See page 7 of Magento Layout Files Reference (see also same document, different format).

Update: The Magento wiki has this defined under Designing for Magento.

Posted on 1 Comment

Maximum length of an email address is 254 characters, not 320

I work in a business of constant learning. Technology is continually evolving and being revised. Somethings are rather constant but, being human, weI tend to develop habits occasionally rooted in wrong assumptions. Perhaps a deadline forced a decision without having time to look up the specification and over time, our mind took that unresearched decision as fact. I’ve made numerous databases over the years based upon just such a wrong assumption. My error has been in the acceptable maximum length of an email address. My number is irrelevant but I am in good company with being incorrect on the length of an email address as many people mistakenly believe it to be 320 characters.

An RFC is a request for comments which "is a memorandum published by the Internet Engineering Task Force (IETF) describing methods, behaviors, research, or innovations applicable to the working of the Internet and Internet-connected systems." (Wikipedia) RFCs set the standards that define how the Internet works. RFC3696 and RFC5321 explain that the maximum length of an email address is 254 characters.

There appears to be some confusion over the maximum valid email address size. Most people believe it to be 320 characters (64 characters for the username + 255 characters for the domain + 1 character for the @ symbol). Other sources suggest 129 (64 + 1 + 64) or 384 (128+1+255, assuming the username doubles in length in the future).

This confusion means you should heed the ‘robustness principle’ ("developers should carefully write software that adheres closely to extant RFCs but accept and parse input from peers that might not be consistent with those RFCs." – Wikipedia) when writing software that deals with email addresses. Furthermore, some software may be crippled by naive assumptions, e.g. thinking that 50 characters is adequate (examples). Your 200 character email address may be technically valid but that will not help you if most websites or applications reject it.

The actual maximum email length is currently 254 characters:

"The original version of RFC 3696 did indeed say 320 was the maximum length, but John Klensin (ICANN) subsequently accepted this was wrong."

"This arises from the simple arithmetic of maximum length of a domain (255 characters) + maximum length of a mailbox (64 characters) + the @ symbol = 320 characters. Wrong. This canard is actually documented in the original version of RFC3696. It was corrected in the errata. There’s actually a restriction from RFC5321 on the path element of an SMTP transaction of 256 characters. But this includes angled brackets around the email address, so the maximum length of an email address is 254 characters." – Dominic Sayers

[Source, EPH, Email Address Length FAQ]

Every day I learn something new! (even when I should have known it for a couple of decades)

Posted on Leave a comment

Project Done

I just put the wraps on one of my projects. This one was a site scrapper and a site rebuild. Scraping means the site which controls the data did not provide an API or other means to get the data so using PHP, cURL, and AJAX (in this case, jQuery), I retrieved the data, used PHP and regular expressions to parse the data to use only the parts I needed, and CSS to present it correctly. The rebuild was applying a new design, furnished by the client, to the rest of the site. Overall fun, albeit with some speed bumps and hiccups.

Posted on Leave a comment

Today’s Work Related Links

I work in an ever changing industry. New techniques, new standards, new languages, new buzzwords are always developing. These changes are why programmers must be constant learners. I learn principles. Specifics of a language simply require a decent reference. I rely heavily upon Delicious as my own personal search engine and reference tool. To date, I have bookmarked 10024 websites. I can spent hours researching a problem and clicking through search engine results to read misinformation or bad links but when I find the resource I need, I bookmark it at Delicious with keywords which will help me find the information easily. The next time I need that info, I can find it in seconds.

Links I have used in my work today:

Posted on Leave a comment

My Clients Now Get P3P Privacy Policies

Does your website collect identifying information on your visitors? If you think because you do not sell anything, ie. no shopping cart, and have no subscription services that you are not collecting identifying information on your site’s visitors then you are probably wrong. Most web servers log IP addresses along with the time of the visit and what that IP address read. ISPs keep logs showing which IP addresses were allocated to what users at particular times. Your logs can be correlated to their logs to identify a person. If your site as a comment form then you are definitely collecting information but more importantly that form gives you a name of a person to associate with the IP address without having to involve the ISP.

So now that we are clear that you are probably collecting identifying information about the visitors to your site, do you have a privacy policy? A privacy policy states how you will use that identifying information. For instance, perhaps you sell it to mailing lists. Or perhaps you specifically do NOT sell it to mailing lists but aggregate it to be able to explain to your potential advertisers that 70% of your site’s visitors are women between the ages of 22 and 35.

If you have a privacy policy, as a human, I can follow the link to that policy, read it, and try to interpret it. But why should I do that when I may not even understand what I’m reading? Shouldn’t the browser or other software handle the privacy policy for me? Yes! And on April 16, 2002 the W3C recommended the Platform for Privacy Preferences Project or P3P which is "a machine-readable language that helps to express a website’s data management practices." What this comes down to is that you can set your privacy preferences in your browser and if the website’s policy does not match, the browser blocks cookies from that site. Certainly there is a bit more to it than that but for most users, it boils down to blocking cookies.

P3P is a bit of a pain in the neck but every website (and that means your blogs) should have a privacy policy. This is definitely something I will encourage of each of my clients.