Teaser Jobausschreibung

Archive for May, 2008

Advanced sorting features for plone folders

Since plone2.5 we’ve got drag&drop support for sorting items in folder_contents view (as long as your content’s meta_type does not contain spaces ;-).

However, drag an drop has the limitation that in a batched view (20 items per page), you can’t move the item on position 20 to 21. You can swith off batching in folder_contents view in recent versions, and there are also patches that enable drag&drop again (see plone3 user manual and issue 7202).

When handling a lot of items in a container, i can think of other useful options such as “move to top”, “move to bottom”, “move n items up/down” or even “sort alphabetically asc/desc”.

In 2006 i wrote a python script for making this (except of sorting) possible for a customer.
It has been ‘released’ in our public svn repository today and I hope this will make other people’s live easier, too:

https://svn.webmeisterei.com/repos/public/plone-tools/moveObjToPos/trunk/

I’m thinking of a more polished version as a small plone package (maybe even with i18n) and adding support for sorting items alphabetically.

Does anybody know if there are already products available that do the same thing?

Are there plans that plone will support a feature like “show items alphabetically sorted” or “ordered reversed” in a folder’s views?

meta_types containing spaces break folder_contents sorting

If you experience problems with sorting/reordering items in folder_contents as i did recently
this might save you from spending > 2 hrs with debugging.

If your folder does contain custom or third party content types that have a space ” ” in their meta_type (see portal_type/ ‘Product meta type’) you most probably ran into the same problem:

If you defined the meta_type of your content type in profiles/default/types/My_Type.xml like that:

<object name="My Type">
  ...
  <property name="content_meta_type">My Type</property>
  ...

objects of your type will have ‘MyType’ as meta_type:

>>> _ = folder.invokeFactory('My Type', 'mytype')
>>> folder.mytype.meta_type
'MyType'

Products.Archetypes.OrderedBaseFolder.moveObjectsByDelta only takes CMF-Types into account.

This is done by using only those ids returned by getCMFObjectsSubsetIds which lists all meta_types registered in portal_types and compares them to the meta_type of the objects contained in the folder.

Since these differ for meta types containing spaces you’ll experience very strange behaviour when reordering items in a folder containing some objects of type ‘My Type’.

Solution:

In case you’re responsible for the product, simply change the GS profile for the portal type from <property name="content_meta_type">My Type</property> to <property name="content_meta_type">MyType</property> and reinstall the product.

In case you’re using a third party product you’re out of luck.
This is why I filed a bug (https://dev.plone.org/plone/ticket/8161)

Install Tabulate without iTunes on Linux

Tabulate will allow you to open links in new windows when browsing websites
on your iPhone.

It normally is installed by adding a bookmark on your Mac/PC and syncing your iPhone with that.

This post will show you how to install it on Linux without using iTunes.

Download the Safary Bookmark file from your iphone.
For firmware 1.1.3 this is in /private/var/mobile/Library/Safari/Bookmarks.plist

Use plutil to convert the binary playlist file to text
so you can modify it:

perl plutil.pl Bookmarks.plist

You’ll find a file named Bookmarks.text.plist

in which you can a new entry for Tabulate:

<dict>
    <key>URIDictionary</key>
    <dict>
        <key>title</key>

        <string>Tabulate - bring open in new tab to iphone</string>
    </dict>
    <key>URLString</key>
    <string>javascript:(function(){head=document.getElementsByTagName('head')[0];if(head){s=document.createElement('script');s.setAttribute('src','http://gadgets.inventivelabs.com.au/tabulate/script');head.appendChild(s);}else{alert('Tabulate-error:document-invalid');}})()</string>

    <key>WebBookmarkType</key>
    <string>WebBookmarkTypeLeaf</string>
    <key>WebBookmarkUUID</key>
    <string>78B2DD0B-3978-4773-8ED0-419027E79BD6</string>

</dict>

All you need to do is to convert your text file to binary, rename it and copy
it back to your iPhone again:

perl plutil.pl Bookmarks.text.plist
mv Bookmarks.binary.plist Bookmarks.plist
scp Bookmarks.plist root@iphone/private/var/mobile/Library/Safari/

To make Safari use the new Bookmarks reboot it by pressing the home button for about 5 seconds.