YouTube full screen mode bug with dual displays

When I use dual displays watching YouTube video, it can not switch to full screen mode correctly. I assume it is because YouTube flash client calculate width and height based on the total of dual displays, and render the video into one display. So it is only displayed in 1/4 size of one display (my two displays are of same resolution).

I have tested how videos from and are rendered in full screen mode with dual displays. I find both of them are fine. So it eliminates the possibility that bug is in Flash Player.

BTW, I did not find a way to stretch the video into two displays.

Lack of jQuery menu UI

I started coding for jqol – thoughts from last week. But I ran into some dilemma.

A very important UI of an eshop is the menu. However, I do not have a mature jQuery UI menu (jQuery menu) widget to use. jQuery menu widget is only available from jQuery UI 1.9, which is still in a stage of milestone 3. The most recent jQuery menu can only theme a flat menu. It can not theme nested (or so called hierarchy) menu. In short, it is useless.

Luckily, Filament Group contributed a very sophisticated jQuery menu UI plugin (fg menu). It can theme flat or hierarchy menu into different styles – flat, flyout, ipod. However, when I try to use it, I find fg menu is based on a different concept to jQuery menu. Fg menu is simulating an OS start menu, and the object being menued is the start button, i.e. use the following code to initialise a menu.

jQuery("button").menu({options}); //menu content inside options

While jQuery menu is exactly a Magento menu, i.e. use the following code to initialise a menu.

jQuery("#nav").menu({options}); //jQuery("#nav").html() itself is the menu content

I am more comfortable taking jQuery core team’s logic, specially in the case of converting Magento menu to jQuery menu widget. Someone from jQuery team has clarified they are of different structures. The status quo is Magento core team’s menu is not completed, but fg menu is something I can use now. So my decision is –

Stay with fg menu for now, and change my code when jQuery menu is mature with all the options I want.

White Rabbit Creamy Candy is available from Tesco

好久不逛 Tesco 了,昨天发现 Tesco 开卖大白兔奶糖。

White Rabbit Creamy Candy

White Rabbit Creamy Candy

不光有大白兔奶糖,还多了一些以前只有在中国店才能买到的食品。我有种莫名的兴奋,虽然大白兔奶糖本身不代表什么,而且自从冠生园月饼事件以后我很少吃大白兔奶糖,但它口味还是我喜欢的,我也希望老外喜欢。我的兴奋,深究一下,大概是因为这些货品的包装跟在中国的销售包装基本保持一致,预示着中国货从 OEM 里走出来了?

Tesco 一向对市场的反应很灵敏。这次 Tesco 又做了一件了不起的事情,在四大超市中首先销售这些货品。我的购物多了一个选择,但中国店主们听了可能会不高兴。

Go to messages inbox back to work

Magento 各测试版的发布很紧密,我有些应接不暇。新功能来不及去试,倒发现一个老功能不灵光了,就是 Magento admin panel 里显示来自官方的 notifications 的 “Go to messages index” 的链接地址不正确,点了仍是当前页面。

因为我有个 fpcp 模块改动了一些 global messages 和 messages 的显示逻辑,是基于 Magento 开发的,一开始我还以为是我的改动与 不兼容。但我把 fpcp 整个 disable,”Go to messages index” 也同样不工作,这下我才想到是 Magento bug。

还没来得及 report bug to Magento,我又发现 Magento rc1 版已经修正了这个 bug。去看了 release notes,果然提到 Fixed “Go to notifications” link works improperly。

Go to messages inbox Latest Message: Magento Preview Version CE is now available Read details

Go to messages inbox Latest Message: Magento Preview Version CE is now available Read details

What does backend type static mean in Magento?

About a year ago, I noticed some category or product attributes, for example, sku, path, etc., were given backend type “static” in class Mage_Catalog_Model_Resource_Eav_Mysql4_Setup. But I failed to find out what static meant here, or I did not know what the difference was between static and datetime/decimal/int/text/varchar. All I knew at that time was if I gave my user defined attribute a “static” type, the attribute values were stored in _varchar table.

Recently, I dived deeper into Magento EAV module. Now I can answer my question.

An entity can have some “static” attributes, whose values are stored in entity main table. Take sku for example, sku values are stored in catalog_product_entity table. Although sku is varchar type, its values are not stored in catalog_product_entity_varchar. Magento does not lookup catalog_product_entity_varchar for sku values because in eav_attribute table, sku backend type is defined as “static”.

It also explains why I can get sku values without add it to select, but I can not do the same with non static attributes.

$collection = Mage::getModel('catalog/product')->getCollection();
echo $collection->getFirstItem()->getSku();

It will output the sku.

$collection = Mage::getModel('catalog/product')->getCollection();
echo $collection->getFirstItem()->getName();

It will not output the name.

$collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('name');
echo $collection->getFirstItem()->getName();

Calling addAttributeToSelect is a must to retrieve non static attribute values.

For user defined attributes of existing entity, if I do not change the structure of main entity table, even I specify backend as “static” in entity setup class, Magento has nowhere to store their values to but fallback to _varchar table.

Establish a protocol of post tags

尽管在 WordPress 里新增一个 post tag 是件很容易的事情,但我不想每次想到一个 tag 就增一个,上千个 posts 就有几千个 tag,搞得 posts 之间的 tag 联系很松散。所以,我很久不新增 tag 了,写完 post 就在已有的 tags 里挑一个或几个 tags 出来。

时代在发展,新生事物不断出现,如果我老用几年前敲定的 tags 而不与时俱进,blog 就显得 out 了,也不利于芳草苑在新新名词方面的排名。比如,刚才一篇,想用 chrome,结果发现有 firefox 而没有 chrome,只好暂时 tag 一个 firefox,等我整理好一份 tag waiting list 再更新 post tags。

初步想删 office, outlook 等,因为 windows 已经 out 了,我也没在 office, outlook 主题上浸淫许久,这类 posts 干脆合并一个 microsoft 或 windows software 得了。

初步想增加 android, html5, css3, jquery, 因为它们或是日渐热门,或是已经热门,我三天两头都会讲到这类主题。现在统称为 google, html, css, javascript 似乎对它们不公平。

Dolphin does not work with HTML5 drag and drop

I use Dolphin in the office, and Nautilus at home. I feel managing files in Dolphin is a little more efficient than in Nautilus, but only a marginal better.

Today I find Dolphin does not support files drag and drop into browser for browser to upload. Drag and drop is an exciting feature of HTML5 and Google has implemented it to Chrome. I quite enjoy using it uploading files to Google Documents.

I would like to use this feature as much as possible but at moment I have to use Nautilus to drag and drop to Chrome. I believe soon I can also use Dolphin to drag and drop to Firefox.

Update layout in Magento against a specific route

I got some complaints to my bxgy module about reminder message is not showing in shopping cart as it supposed to be. But I checked over and over on my machine and did not find anything preventing reminder message being shown.

By a chance I realise maybe those people changed Magento interface and theme in a not nice way. What is a nice way? By my definition, any extension or change to Magento original code should make sure

  • do as few changes as possible
  • Magento default theme can always be fallen back to

I take it as a basic requirement of customisation, but I can not guarantee everyone else see it through. If I rely on a module layout xml file to trigger an action against a specific route, I get a higher chance of my layout xml file being bypassed by some incompatible theme.

In bxgy module version 0.1.0 to 0.1.1, I wrote a layout handle checkout_cart_index in bxgy.xml, which is expected to add a message to the message block against route checkout/cart/index. If bxgy.xml is bypassed (when the theme settings do not take default theme fallback into consideration), nothing will happen. Do I have to use layout xml file to trigger an action against a specific route? Absolutely not. There are many ways around.

In a newer version of bxgy module, I use an event observer to trigger “controller_action_postdispatch_checkout_cart_index” event, and add message to the message block in this observer. Because adding reminder message is something more relevant to functionality than presentation, the code’s logic is better if it is moved from design folder to app folder. And event observer is independent of theme settings.

BTW, I finished coding this new version of bxgy, but I want to put together some other modules before release it.

My new thoughts about jQuery in Magento

Today, I have two new thoughts about jQuery in Magento.

Firstly, I will stop using a jQuery plugin called jQuery corner. It is a great plugin though. The reason of withdraw is jQuery corner plugin rounds elements with any radius I can specify on the fly. Once upon a time I thought dynamic cornering a great feature. However, jQuery UI comes with ui-corner classes. It has fixed value of radius for all round corners. It does not let me round different elements to different radius, but guarantees the consistency. In this case, consistency is much more important than flexibility. When I do want make exceptional larger or smaller radius for some kinds of elements (one or two kinds at most), I can code css just for that class.

Secondly, I will start a new Magento module project called Jqol. It reads “JQuery themerOLler”, or “JQuery OnLine” (whatever you feel easier to remember). I am inspired by how easy it is to use jQuery Themeroller to build and change the look and feel of a website. It is a pity Magento does not come with jQuery. I keep mention it because I can not live without jQuery (for now). I implemented jQuery the very first thing when I started diving into Magento. While jQuery is getting stronger and more popular, I would like it play more important role in Magento. Therefore, I will let jQuery Themeroller control the look and feel for the top menu, buttons, accordion, tabs, etc. I can imagine a lot of benefits from this module: cleaner code, more semantic, and I (or even visitors to my sites) can switch the jQuery themes easily.