Skip to content
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

Fix parameter name on pods_field_display #7293

Open
russell-edsvcs opened this issue Apr 17, 2024 · 3 comments
Open

Fix parameter name on pods_field_display #7293

russell-edsvcs opened this issue Apr 17, 2024 · 3 comments
Assignees
Labels
Status: Need User Feedback Waiting on feedback from user who reported issue Type: Bug
Milestone

Comments

@russell-edsvcs
Copy link

Description

The first parameter of pods_field_display is a $pod, but if you actually give it a pod object it doesn't work. Looking into this function, it passes this parameter to https://docs.pods.io/code/pods/ as the $type parameter. Therefore, the first parameter of pods_field_display should probably match pods() and be named $type.

Version

all

Testing Instructions

No response

Screenshots / Screencast

No response

Possible Workaround

No response

Site Health Information

No response

Pods Package

No response

@sc0ttkclark
Copy link
Member

The code for that is currently:

/**
 * Get a field display value from a Pod.
 *
 * @param string|null  $pod    The pod name, or if you are in The Loop then you can just provide the field name to auto-detect pod/id using loop information.
 * @param mixed|null   $id     The ID or slug of the item.
 * @param string|array $name   The field name, or an associative array of parameters.
 * @param boolean      $single For tableless fields, to return the whole array or the just the first item.
 *
 * @return mixed Field value.
 *
 * @since 2.1.0
 */
function pods_field_display( $pod, $id = null, $name = null, $single = false ) {

Are you just saying that the name of the argument should match the older $type argument name used in pods()?

@sc0ttkclark
Copy link
Member

Question for you -- what's the use case for calling pods_field_display() with a Pods object? Why wouldn't you call $pod->display( ... ) instead?

@sc0ttkclark sc0ttkclark added the Status: Need User Feedback Waiting on feedback from user who reported issue label Apr 22, 2024
@sc0ttkclark sc0ttkclark added this to the Backlog milestone Apr 22, 2024
@sc0ttkclark sc0ttkclark self-assigned this Apr 22, 2024
@russell-edsvcs
Copy link
Author

The code for that is currently:

/**
 * Get a field display value from a Pod.
 *
 * @param string|null  $pod    The pod name, or if you are in The Loop then you can just provide the field name to auto-detect pod/id using loop information.
 * @param mixed|null   $id     The ID or slug of the item.
 * @param string|array $name   The field name, or an associative array of parameters.
 * @param boolean      $single For tableless fields, to return the whole array or the just the first item.
 *
 * @return mixed Field value.
 *
 * @since 2.1.0
 */
function pods_field_display( $pod, $id = null, $name = null, $single = false ) {

Are you just saying that the name of the argument should match the older $type argument name used in pods()?

Yes, that is what I was trying to say. It doesn't make sense to call the same thing two different names, and it confused me when I encountered it, so I thought I would report it. Side note, I have no idea why the heck I used the word therefore like that in my original post 🤪. I think that was left over from something else I was going to say. Ignore that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Need User Feedback Waiting on feedback from user who reported issue Type: Bug
Projects
None yet
Development

No branches or pull requests

2 participants