• Resolved lanzoninicola

    (@lanzoninicola)


    Dear Support,

    I am using the field method of Pod class in my code and I noticed that the method does some checks (is_object, is_array etc…) of the name parameter but the method does not check if the name variable passed to the function is an empty string.

    I appreciate that the method also checks for empty string and in this case the method could return null or false like another use case.

    I’m not an experienced PHP developer, so I hope I haven’t alerted you to nothing.

    Thanks

    • This topic was modified 3 years, 3 months ago by lanzoninicola.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @lanzoninicola

    Could you elaborate on the reasoning behind this topic?
    If you don’t pass a name param you will get a null response:
    https://github.com/pods-framework/pods/blob/main/classes/Pods.php#L861-L863

    Cheers, Jory

    Thread Starter lanzoninicola

    (@lanzoninicola)

    Thanks @keraweb for the reply.

    You are right, I see the code and the case is supported (sorry for my mistake).

    Here the context (maybe you are a better solution for this):

    Typically, I create a settings page called “Theme Editor” for my clients to edit the website I build for them using the Pods custom settings page. It’s very useful because my clients are autonomous in modifying certain parts of the website (I’m using a combination of a page builder: Bricksbuilder and PHP code to develop the front-end).

    In this case I created a new custom page that allows the client to choose the product categories (Woocommerce) to be rendered in the page based on their relevance to their business.

    Depending on the relevance I render the “title”, “description” and “image” of the product category in different parts of the homepage.

    If I use the shortcode [pod name=”name_of_pod” field=”name_of_field”] (based on my little experience of your plugin and some research in this forum) it only renders the product category name, which is the value contained in the field of the custom settings page.

    But in the front-end I would need to render the product category data as I mentioned before.

    Is there any other way to do this based on your knowledge of the plugin?

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

    (@keraweb)

    Hi @lanzoninicola

    Did you see our introduction video?
    https://docs.pods.io/videos/grow-beyond-posts-pages-introduction-pods-framework/

    With Pods templates you can create your own views with all relational data you want.
    You can even manually include fields in your shortcode:

    [pod name="name_of_pod"]Your template {@field_one} and {@field_two}[/pods]

    Cheers, Jory

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Class Pod – field method – name variable is empty string’ is closed to new replies.