fortiernor
Forum Replies Created
-
Forum: Plugins
In reply to: [flowpaper] PHP warningPlugin works overal, but that warning message is filling my logs. Please correct!
Forum: Plugins
In reply to: [Code Snippets] How to include an separate php fileThank you!
Thank you, Jory. As I’m building a single site for an small environmental group (as a volunteer), I’m not going to delve into wp any more than is strictly necessary, and I certainly don’t intend to repeat the experience.
In my active career I spent 20 years programming in Java (with Web frontends), and the major shock with the wp “ecosystem” is the absence of everything that made development stimulating and a deep learning experience. It’s like being back in 1995 (and not on the forefront of development even then).
Thanks for your help.So adding a field to a custom type with existing instances does not update these instances, and that field is not queryable. In my case it meant:
– figuring this out, not obvious at all since this is a wordpress idiosyncracy;
– reediting all my documents. Since there are 18 of them, no big deal! But it does mean that adding a field to a pod with many instances is not feasible.Would you at least consider documenting that behaviour, preferably in the faq, in tutorials and in your admin UI? Ideally, please also provide a php snippet that one could run in some way to initialize null fields in that use case.
Thank you!——
SELECTDISTINCT
t
.*
FROMwpnf_posts
ASt
LEFT JOIN
wpnf_postmeta
ASinterne
ON
interne
.meta_key
= ‘interne’
ANDinterne
.post_id
=t
.ID
LEFT JOIN
wpnf_postmeta
ASdate_doc
ON
date_doc
.meta_key
= ‘date_doc’
ANDdate_doc
.post_id
=t
.ID
WHERE ( (
interne
.meta_value
IS true ) AND (t
.post_type
= “document” ) AND (t
.post_status
IN ( “publish” ) ) )ORDER BY
date_doc
.meta_value
DESC,t
.menu_order
,t
.post_title
,t
.post_date
—–
>If you are using table based fields then the column always exists but might be null instead of false or 0, depending on your field required setting and whether the post exists pre-adding the field or not.That is my point: in MySQL adding a boolean field with a default value to a table with existing rows initializes it properly to the default value for all existing rows, whereas pods (or wordpress or whatever) does not.
Thanks for pointing the not-always-obvious nature of mysql booleans.
However that is not the issue: once I edited and saved every document (see my previous message), the where clause using either
- interne.meta_value = FALSE
- NOT interne.meta_value
works perfectly.
To make sure I added another Yes/No field to the document pod, without editing any of the documents. I tried with a default value of ‘No’, a default value of 0, and no default value. The results are all the same: no documents are returned from the following where clauses:- testing.meta_value IS true
- testing.meta_value IS false
- testing.meta_value
- NOT testing.meta_value
- testing.meta_value = true
- testing.meta_value = false
- testing.meta_value = 1
- testing.meta_value = 0
whereas all these clauses work as expected with documents that have been re-edited and saved after the field has been added.
Is this really a MySQL issue? I downloaded a sample mysql db and added a boolean column:
> ALTER TABLE products ADD COLUMN testing BOOLEAN DEFAULT 0;
> select * from products where NOT testing;
-> 110 rows in set
> select * from products where testing;
->Empty set (0.001 sec)So it is not a question of MySQL behaviour or MySQL syntax, but with the fact that the field is not initialized properly when inserted into the database.
In other words, a Pods bug.- This reply was modified 4 years, 5 months ago by fortiernor.
It seems this happens because I added the field after I had entered a number of documents. The field content it seems is then an array, not a boolean (the joys of loose typing?).
The workaround is then to edit each document by hand, setting the value of the field to “yes” (“no” is the default), saving it, editing it again to set the value of the field to “no”.
Not too impressed.Forum: Plugins
In reply to: [Pods - Custom Content Types and Fields] How to use orderby in shortcodeThank you. I’ve found an obvious workaround for my simple problem: simply order the child entities correctly, by using the List view for the field in the admin form.
I realize I should look into php to get a real sense of what is possible or not in wordpress and Pods (after 20 years of java programming, I should be able to understand at least the simpler stuff…). Could you suggest resources for learning, not php itself, not code reference such as Pods offers, but rather a high-level view of how it all ties in?Thank you again.
Forum: Plugins
In reply to: [Pods - Custom Content Types and Fields] How to use orderby in shortcodeI’ve noticed another problem. If I call the template through a pods shortcode in the pods single item widget, such as explained above, then for each enjeu all interventions will be listed, even if the enjeu does not contain any. It seems the shortcode above is not “scoped” within the parent enjeu.
Should I conclude that one should not call a pods template from a pods shortcode?Ha! I used the first approach and it works fine. Thank you so much!
Normand
Hi @keraweb,
You’re right, it is much simpler to delete the “source” and “shortcode_document” fields, and instead create a relationship field to “media”, then select the pdf file in the media library. I can then insert a pods single widget in my page and specify the pods template for display. For testing, I can create a link on my page using that. (The template will use {@field._src})
However if I generate a shortcode instead of a link, the shortcode is simply displayed as plain text on the page, it is not “interpreted” as a shortcode. I guess the only way that can happen is by inserting the shortcode into the post content (the cumbersome way).
My original question was mistaken as I thought displaying the shortcode would result in it being executed.
Thanks!