New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to find key/value pairs #141

Open
JoshuaLuckers opened this Issue Jun 3, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@JoshuaLuckers
Copy link

JoshuaLuckers commented Jun 3, 2018

I use CakePHP at work and I love how easy it is to find key/value pairs.

This would also be very useful in for example MODX. It would make it easier to show the "display name" of a system setting (like the name of the default template) instead of the value for the primary key.

Example from CakePHP:

It is often useful to generate an associative array of data from your application’s data. For example, this is very useful when creating elements $query = $articles->find('list'); $data = $query->toArray(); // Data now looks like $data = [ 1 => 'First post', 2 => 'Second article I wrote', ];

@opengeek

This comment has been minimized.

Copy link
Member

opengeek commented Jun 3, 2018

I do not understand the example you've provided. That seems like a simple convenience method for "listing" the page titles. You can quickly build a PDO query in xPDO to do this as well, so a little more context would be helpful here.

@JoshuaLuckers

This comment has been minimized.

Copy link

JoshuaLuckers commented Jun 4, 2018

You are right, I should give a bit more context. I will do that later this week.

@JoshuaLuckers

This comment has been minimized.

Copy link

JoshuaLuckers commented Jun 9, 2018

In MODX for example there are various places where a "displayField" would be useful.

For example, templates:

In most cases we always want to show it's name. In dropdown, system settings etc.
Yet in system settings it now displays the value of the "primary key". If we could define a displayField next to a primary key we have the possibility to be consistent in the way we show values. The "primary key" could then be used as value while the "displayField" is being used for the label.

This way the "model" of the object defines how it should be displayed making it easier for others.

And yes, its a convenience method but I'm sure it would be a great addition for a lot of snippet/chunks developers.

@netProphET

This comment has been minimized.

Copy link
Member

netProphET commented Jun 12, 2018

How does that work when you wish to localize the component for another language? Having a singular displayField would seem to lock it to one language.

@JoshuaLuckers

This comment has been minimized.

Copy link

JoshuaLuckers commented Jun 12, 2018

In CakePHP they have behaviors. For entity/object translations you can use the TranslateBehavior. I have to dig a bit deeper into xPDO to check how this can be accomplished in xPDO.

Of course I don’t want xPDO to become CakePHP, but I do find it handy how they solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment