First, thanks for this nice module.

I think the arrays produced can be made more useful if there was an option to produce a shallow array with simple key value pairs. I specifically needed this to provide an array of allowed values for a CCK field , based on a view that exposes a custom database table.

I don't know how to add options to select the key and value fields to the view style options. after some hard coding I was able to produce an array that looks like this :

array ( 'keya' => 'valuea', 'keyb => 'valueb')

If I find out how to add options to the view style, I'll post a patch to implement this.

CommentFileSizeAuthor
#1 views_php_array_shallow.patch.txt2.36 KBiamer

Comments

iamer’s picture

Status: Active » Needs review
StatusFileSize
new2.36 KB

I figured it out, here's an initial patch to implement this. I am sure the wording and logic could use some polishing. Pointers welcome :)

adityakg’s picture

If I am not mistaken, you want the option to specify the array keys in the result? Thanks for the patch. I will look through it by this weekend ;)

iamer’s picture

That is correct. But there's more.

The patch adds two select fields , one to specify the field to use for the result array keys. The other one is to specify the field to use for the value of the result array.

Let's say you have a view that has two fields : 1- Name 2- Color , I want a result that looks like this : array ( NameA => ColorA , NameB => ColorB )