jjci
Forum Replies Created
-
Forum: Plugins
In reply to: [Pods - Custom Content Types and Fields] Customized WHERE – documentation?Thanks to all for the conversation so far.
I must confess that I still don’t understand the purpose/benefit of using this feature at the field-level as opposed to defining the appropriate ‘where’ clause(s) at the application level.If possible, could someone outline a simple example which illustrates how this works and where it’s appropriate to apply it?
Thanks. JJCI
Forum: Plugins
In reply to: [Pods - Custom Content Types and Fields] Customized WHERE – documentation?Jory,
Thanks for your quick response.
However, my original question still remains. I need to understand WHY I would use this feature to specify a condition at the field-level, as opposed to coding the specified condition into one or more ‘where’ clauses at the application-level.
What am I missing?
Also, just to clarify, this is significant to me because I am developing a set of 6-8 separate custom post types which employ parent-child relationships.
- This reply was modified 3 years, 10 months ago by jjci.
If possible, can you provide more details on the solution that you developed and implemented?
Your solution may be useful and applicable to others facing a similar issue.
Thanks.
JJCI
So, what was the explanation?
Was there a ‘repair-based’ solution? A work-around?
It would be helpful to know.
- This reply was modified 3 years, 11 months ago by jjci.
This may be relevant to other people trying to do the same thing.
What was the problem? And, what was your solution?
Perfect. Thank you.
Understood. Thanks.
Based on what I could gather from the code, I tried to retrieve the pod entry ID from various elements of the $pieces array. However, nothing worked.
1) Would the ID value even be available during a pre-save procedure if the pod entry was being created (as opposed to updating an existing pod entry)?
2) Within the $pieces array, would I be more likely to find the pod entry ID in the ‘object_fields’ array, the ‘fields’ array, or the ‘params’ array?
Just to clarify, the number of parameters was already set correctly (i.e. 3).
Based on my earlier tests, the ‘$id’ value is coming in as ‘0’.
Further, I tried to retrieve the id value from the $pieces array using keys ‘post_id’, ‘post_ID’, ‘id’ and ‘ID’. However, none of those keys returned anything.
Rather than guessing, is there any documentation which would describe all of the available key values (e.g. “post_title”)? Or, would this list simply be the basic post elements in addition to the fields that are specific to my CPT?Is there a specific configuration required in order to cause the hook to populate the third parameter (i.e. $id)?
Another additional note (which is a workaround to the original problem):
If I select Custom Post Type, the “Advanced” link does not work therefore I cannot enter a name for the new Pod.
However, if I select Custom Taxonomy (or Custom Settings) the “Advanced” link opens correctly. At that point I can change my selection to Custom Post Type and the “Advanced” link content remains open allowing me to specify the name for the new pod. The creation of the new pod fields works correctly from that point.
The same problem occurs if I attempt to create another new POD CPT. However, I can easily employ the workaround described above.
An additional note:
On the first page, the “Advanced +” link is not working, i.e. clicking on it does not change the screen. However, the same link works for a new Taxonomy and for a new Custom Settings Page.
That worked perfectly. Thanks.
Please close this ticket.
The code is below:
add_filter( ‘gform_field_value’, ‘gform_field_value_6_1’, 10, 3 );
function gform_field_value_6_1( $value,$geld, $name ) {$pods_loc_ID = $_GET[‘parm1’];
$pods_loc = pods(‘tgz_cpt_locs’,$pods_loc_ID);
$pods_loc_title = $pods_loc->field(‘post_title’);$related = $pods_loc->field(‘parent_tgz_cpt_organization’);
if ( ! empty ($related)) {
foreach ($related as $rel) {$pods_org_ID = $rel[‘ID’];
$pods_org_title=get_post_meta($pods_org_ID,’supportcandy_organization’,true);
$pods_org_ID_formatted = “[” . $pods_org_ID . “]”;
$pods_org_reference = $pods_org_ID_formatted . ” : ” . $pods_org_title;
$pods_loc_reference = $pods_org_ID_formatted . “[” . $pods_loc_ID . “]” . ” : ” . $pods_loc_title;
}
}
$values = array(
‘TGZ-CPT-Organization_reference’ => $pods_org_reference,
‘TGZ-CPT-Location_reference’ => $pods_loc_reference
);
return isset( $values[ $name ] ) ? $values[ $name ] : $value;
}So, if the page URL contains a ‘parm1’ value of 749, it is used to correctly retrieve the Location entry. However, the ID value of the corresponding parent Organization is 465, and this value is contained in the ‘$related’ array (based on inspection of the var_dump). However, the code appears to make several loops through the array values and never returns an ID value of 465. As noted, if the code is modified to use a hard-coded value of 465 for the Organization ID, everything after that point works exactly as it should.
Is there another method that should be used to retrieve ‘parent’ information that does not require a loop? That is, there should only be a single parent entry to retrieve, so why would it be necessary to use a loop to get to it?
Thanks for your very prompt response.
I will update my setup and then do some preliminary testing. Will advise results.
Thanks,
JJIssue resolved.
The support was very good regarding the clarification of the default parameters and how to access specific elements of them.