• Resolved jjci

    (@jjci)


    I suspect that the ‘Customized WHERE’ feature may be useful to my requirements.
    However, I cannot find any meaningful documentation about its use. That is, at this point I am more interested in knowing WHY I would use it (as opposed to the details of how to implement it).
    Also, would applying this particular feature imply that all ‘where’ clauses associated with the pod/field would include the specified condition by default?

    As you can see, I am really not sure how I would apply this particular feature.
    Some realistic examples would be helpful.

    Thanks.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @jjci

    This is a more advanced feature of Pods.
    In this field you can set some basic SQL filtering for the relationship results.
    Example:
    post_title LIKE "%Foo%" to show all posts that contain “Foo” within their title.

    Cheers, Jory

    Plugin Author Jory Hogeveen

    (@keraweb)

    Oh, keep in mind that there is a sanitizing issue in the current release:
    https://github.com/pods-framework/pods/pull/5910

    Thread Starter jjci

    (@jjci)

    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.

    Hi JJci
    I am having the same problem as I don’t know the right syntax to use to filter a CPT with a related Taxonomy.

    Where is basically a filter and you use a field in a taxonomy or category to return only those results.

    So if you had a Taxonomy that has values of A, B and C and you would like to filter B and C out of the results and just leave A then you would use Where.

    i.e Where taxonomy name = “A”

    How you use it is a mystery at the moment. In a database this would be known as a Query.

    Hopefully that explains that and no doubt Jory will be back and help us how to actually use it.

    Morris

    Curious about this as well. I am building an online index for a story my wife is writing. Rather than creating different but similar pods for Characters, Locations, Objects, Seasons, etc to index them, I am hoping to create a single Elements pod with a field to indicate whether an entry is a character element, location element, object element, etc. The values for this field come from a custom taxonomy called Element Type. Each Element is assigned an Element Type.

    This would give a full table of all story elements for generating an index, but it’s already getting unwieldy seeing the whole list on each selector when creating a new chapter.

    The Chapters pod has fields with selectors for Season, Location, POV Character, and more. These all reference the Elements pod.

    What I am hoping to do is have the Location field for each chapter show only those elements with an element type of Location to select from, the POV field show only the Character elements to select from, etc. But then be able to parse and sort the entire Elements table to build an index or browse/search.

    Clear as mud?

    Short version: I have an Elements pod with a Type field. That Type field is related to an Element Types taxonomy. I want to use a Customized Where clause to show only Elements with a Type of “Character”. Is this possible? And if so do I need to downgrade or hold until the fix?

    Hi
    Yes there is a bug in the latest Pods version and it won’t work using the Where clause. See below:

    Bug in Pods version 2.7.26

    You need to downgrade to 2.7.24 for the Where clause to work. I did that and now I can’t add anything New in Pods.

    Because I am doing a Church’s website I wanted to filter for either Baptism, Marriage or Burial from the registers and I used the following in the Customised Where text box as:

    ceremony_type.name=”baptism”

    ceremony_type was a taxonomy.

    I hope this helps in the meantime as I spent 2 days trying to get the Where clause to work.

    Morris

    • This reply was modified 3 years, 10 months ago by morris373.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi everyone.

    @jjci 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.

    As for “why”. This is handy to filter the resulted relationships based on a property of the related object.
    If that doesn’t answer your question it’s most likely you don’t need it ??

    @morris373 I am having the same problem as I don’t know the right syntax to use to filter a CPT with a related Taxonomy.

    (@redwoodskwerl, below also goes for your question)
    The syntax would be taxonomy_name.slug = "a" where taxonomy_name should be replaced with the name of your taxonomy.

    You need to downgrade to 2.7.24 for the Where clause to work.

    A fix can be found here:
    https://github.com/pods-framework/pods/pull/5910

    Please let me know if it works for you after thorough testing while saving Pods and fields.
    This patch 100% relies on users to test it before it will be merged into Pods core so if you need this patch to be release fast, please test it thouroughly a.s.a.p.!

    Cheers, Jory

    • This reply was modified 3 years, 10 months ago by Jory Hogeveen.
    • This reply was modified 3 years, 10 months ago by Jory Hogeveen.
    • This reply was modified 3 years, 10 months ago by Jory Hogeveen.
    Thread Starter jjci

    (@jjci)

    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

    Hi
    I have 1 CPT called Ceremonies, which is based on a Church’s Registers eg Baptisms, Marriages and Burials. I have another CPT called People which is related to the Ceremonies CPT.

    I also have a Taxonomy called Ceremony Type and I can select one depending on the Ceremony that I am adding for a person.

    When I view All Ceremonies I can see all of them and see that I have Baptisms, Marriages and Burials all mixed in.

    If I want to add a Ceremony of a Burial to a person in my People CPT, I would need to select it from the Ceremonies dropdown but I will have Baptisms and Marriages all mixed in as well. So if I use the Where clause I can set it to ‘Burials’ only and that will filter out Baptisms and Marriages so now I can just search through the dropdown just has Burials in it and find the right one, well that’s if I have already have added a Burial for that person.

    I could get a bit more clever here by using Where and add the Surname that would then filter all of the Surnames to that particular name. If it wasn’t found, then I haven’t added it so I would then just click on Add New and add it.

    Hopefully that explains the Where clause and how I used it.

    Morris

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Customized WHERE – documentation?’ is closed to new replies.