Just another WordPress.com site

Posts tagged ‘update’

User-editable text metadata | Pydio, formerly AjaXplorer

A common need for a system like AjaXplorer is to let the users enter their own comments or remarks about the files they use. AjaXplorer lets you simply define as much metadata fields as you want, with various field types available, through this plugin meta.user.

This plugin requires a « metastore » plugin to be active to do the actual storing implementation. If you are not sure of what this mean, just read the previous section. Metastore will handle the actual storing of the metadata, where as the plugin will handle how it is displayed and other users interface.

Metadata is attached to a file, which means it is moved/copied/deleted between folders when such operations are applied on the files. The plugin provides a little editor for adding/modifying these properties as simple text lines, display them in both the file list and in the infoPanel, and the added metadata is also searchable.

To add some metadata fields, simply follow the steps :

In the « Repository Features » of a workspace configuration panel, make sure a MetaStore is defined, and add a « Text Metadata » plugin to the stack.

You can see a replicable set of three fiels :

Meta Field: a technical name for the field. Please use only alphanumerical characters. See below for specific keywords.

Meta Label: will be displayed to the user

Column visibility: can be « visible » or « hidden » (without quotes). This defines whether in List mode, the associated will be visible by default or not.

Some special keywords can be used to name metadata fields, that will behave specially in terms of GUI :

stars_rate : the field automatically turns into a 5-stars rating system for the files. View and edit the rating directly in the InfoPanel, in the FilesList (in list mode only for the moment), and in the « File Meta Data » form.

css_label : the field turns into a labeling system that will apply a given css class to either the table row when in list mode, or the thumbnail cell when in thumb mode. The css classes are defined in plugins/meta.serial/css and by default they define 5 levels of priority with associated background colors. Use png transparent images as background colors, that way the user can still notice when a row is selected or not.

area_XXX : Prepending « area_ » to a field name will create a textarea field.

For example, here is below a correspondance between a set of configuration and the result for the end user :


via User-editable text metadata | Pydio, formerly AjaXplorer.

Ordering Menu Items Alphabetically

Faced with a tedious task of ordering a set of rows using a weight column? Don’t want to type the numbers out? Would rather find a difficult but more interesting method? I have the answer for you!

In Drupal, menu items (like the projects list on this site) are ordered by giving each one a weight. This means you can order the items in anyway you like! The problem I had was I imported about 60 menu items but not in alphabetical order. I didn’t really want to type all the numbers out again so I sought out a less tedious but much more complicated method – its what I do!

I quickly produced a simple select query which ordered my list…

SET @cnt = 0;
  mid, title, weight,
  @cnt := (@cnt + 1) AS row_number
FROM menu
WHERE pid=36
ORDER BY title;

This selected all menu ID’s, title’s, weight’s and a row count column which incremented a variable called cnt, filtering the list by menu items with a parent ID of 36 and ordering by the title (default ascending). This produced a list like this (EXAMPLE):

ID Sport Weight Row Count
13 golf 19 1
1 rugby -2 2
4 soccer 11 3
20 swimming -8 4

This table shows that the only ordered columns are the title and row count, but the weight (which is used by Drupal) is NOT ordered… This means we’re half way to a solution!

Unfortunately, with the UPDATE command, you cant use the variable column additionally as you would in a select (eg, above)… However I have learned that you can include the formula part in the set section of the UPDATE… I shall Explain by example!

SET @cnt = 0;
SET weight = @cnt := (@cnt+1)
WHERE pid=36
ORDER BY title;

Same situation as above, (filtering and ordering) – basically I want to update all menu items with a parent ID of 36, ordered by title in ascending order and I want to set the weight to the value of @cnt which itself is equal to its current value plus one

I ran that and was politely told that a number of rows had been updated, so I ran the select again and was shown:

ID Sport Weight Row Count
13 golf 1 1
1 rugby 2 2
4 soccer 3 3
20 swimming 4 4

I hope this helps people out – certainly taken the mundanity out of that job!

%d bloggers like this: