Forum Replies Created
-
AuthorPosts
-
cosmocanuckMemberThanks Steve, that’s awesome. I even managed to further customize it with a title field to name each component.
It was tricky though… bit of a pretzel logic thing… and I did look for a rundown on the use of Groups and Columns in the tutorials section, but couldn’t seem to find anything that really explains it – it’s listed here:
https://piklist.com/user-guide/docs/field-parameters/
But it doesn’t really explain when they “kick in” and how to use them… might be something for a future embellishment to the User Guide…
But bottom line, thanks a million for helping with this, and I will certainly study, and hopefully learn from, your example!
adam
November 10, 2014 at 12:46 pm in reply to: Custom Post Type archives and posts giving a 404. Piklist bug? #2730
cosmocanuckMemberJason, that was one of the best programming-related laughs (heck, any kind of laugh) I’ve had in some time, thanks! I’m going to paste that up on my wall to help keep me sane when this sort of thing happens again!
Steve – thanks and I’ll keep that in mind in the future!
November 10, 2014 at 1:12 am in reply to: Custom Post Type archives and posts giving a 404. Piklist bug? #2697
cosmocanuckMemberOK, you’re going to think I’m crazy – and I might agree with you – but the page has returned to full functionality!
This, without me touching or changing anything. Mere minutes after I posted my issue here.
While I’m happy it’s working now (and that – I presume – it wasn’t Piklist’s fault in any way!)… I sure am not reassured that it won’t go away again. For a reason I seemingly can’t ever know. Ugh.
Well, I’ll assume things are fine, and there certainly is nothing you can troubleshoot, but if you have any thoughts at all, I’d welcome them.
Thanks again!
adam
cosmocanuckMemberAwesome. Thanks Marcus!
cosmocanuckMemberIf you have time…
I’m trying to reference the specific fieldnames, to avoid the .each method and allow the use of the existing data… but am unclear (being a JS fairly-newbie) on how I reference the Piklist fields. I see you’re using
‘input[id^=”_post_meta_calcme_”]’
But the old code that once worked, used constructions like:
lifts1 = document.post[“post_meta[trams]”].value;
How would I refer to the fields correctly to simply total up the value of the specific fields I’d like to summarize?
Thanks…
cosmocanuckMemberHi again Marcus!
Hey, I realized that there was an unintended consequence in my using that fine JS code of yours. Since I had to rename the relevant metafields for the calc to work, all the data my client already entered in for those – in 130+ posts – is no longer being used or displayed. Well, the front end was OK, but only because it was grabbing the old fields.
Instead of making my client re-enter all those numbers, I’m wondering if the script could simply do a hard-coded calc of the needed fields, as they already are named, instead of the (admittedly efficient and nifty) approach of custom-naming the fields and using the “each” function.
Not pretty I know, but this field configuration is not going to change, and if it does, I’m happy to hard-code a fix.
Let me know… thanks!
Adam
cosmocanuckMemberMarcus, you are truly a god of Javascript!
Well, at least, you’re way more expert than me. 8^)
I’m inspired to renew my Java self-education efforts! It’s hard when it’s only occasionally that this stuff comes up… so I never have the opportunity to really dig into it. (And long gone are my single/childfree days when I could stay up half the night absorbing some new coding knowledge just for the fun of it!)
Anyway, bottom line, it works great and THANK YOU for the revised code!
All the best!
Adam
cosmocanuckMemberThanks a million Marcus! I followed your instructions to the letter, AFAIK – and have confirmed that your script is loading – but I’m not seeing any auto-summing.
Here’s what I’ve done for the autosum fields in the metabox file:
piklist('field', array( 'type' => 'text', 'field' => 'calcme_trams', 'label' => __('Trams'), 'position' => 'wrap', 'attributes' => array( 'class' => 'text', 'columns' => 2, 'onFocus' => 'calcMe();' ) ));…and here’s what i did for the grand-total field:
piklist('field', array( 'type' => 'text', 'field' => 'finalcalc_total_lifts', 'label' => __('Total Lifts'), 'position' => 'wrap', 'attributes' => array( 'class' => 'text', 'columns' => 2, 'readonly' => "readonly" ) ));But nothing happens.
Any idea what might be amiss?
Thanks again,
Adam
cosmocanuckMemberIt was 0.9.1. Not 100% sure that this feature was indeed working with that version as it didn’t come up as an issue till recently, but it seems to be the case. Currently on 0.9.3 on the new (final) server.
cosmocanuckMemberHi guys! I had this working beautifully – I invoked a function for a bunch of numerical Piklist fields, all coded similar to this:
piklist('field', array( 'type' => 'text', 'field' => 'surface_lifts', 'label' => __('Surface Lifts'), 'position' => 'wrap', 'attributes' => array( 'class' => 'text', 'columns' => 2, 'onFocus' => 'startCalc();', 'onBlur' => 'stopCalc();' ) ));…and for the autosum field, I did this:
piklist('field', array( 'type' => 'text', 'field' => 'total_lifts', 'label' => __('Total Lifts'), 'position' => 'wrap', 'attributes' => array( 'class' => 'text', 'columns' => 2, 'readonly' => "readonly" ) ));and it used this JavaScript:
function calc(){ lifts1 = document.post["post_meta[trams]"].value; lifts2 = document.post["post_meta[gondolas]"].value; lifts3 = document.post["post_meta[hs_sixpack]"].value; lifts4 = document.post["post_meta[hs_quad]"].value; lifts5 = document.post["post_meta[hs_triple]"].value; lifts6 = document.post["post_meta[quad_chairs]"].value; lifts7 = document.post["post_meta[triple_chairs]"].value; lifts8 = document.post["post_meta[double_chairs]"].value; lifts9 = document.post["post_meta[surface_lifts]"].value; document.post["post_meta[total_lifts]"].value = (lifts1*1) + (lifts2*1) + (lifts3*1) + (lifts4*1) + (lifts5*1) + (lifts6*1) + (lifts7*1) + (lifts8*1) + (lifts9*1); } function startCalc(){ interval = setInterval("calc()",1); } function stopCalc(){ clearInterval(interval); }But after the move to the final server – plus a Piklist update – it doesn’t work. I get this error:
TypeError: ‘undefined’ is not an object (evaluating ‘document.post[“post_meta[trams]”].value’)
…implying it’s failing when trying to get the first value.
I apologize that my Javascript is pretty rudimentary, but I wanted to check with you guys in case it might be something to do with Piklist, or perhaps how I’m supposed to reference the metafield variables has changed…
Thanks!
adam
cosmocanuckMemberOK, I shall wait a bit!
cosmocanuckMemberAnyone else experiencing what I am? On my Plugins page, I click to install the update… it gives the usual status report and success message… but when I return to my Plugins page, it still says I’m running 0.9.0 and that the update is needed.
I assume I can manually update by removing the previous version and FTP’ing the new one, but figured i should mention it.
cosmocanuckMemberSteve, thank you so much! The error is fixed, the title is in place, and the archive works.
I’m feeling more like a power WP coder every day. But it’s a little “two steps forward one step back” sometimes. This kind of help makes such a difference. Thanks again.
Adam
cosmocanuckMemberHi again guys. Not sure why the error reported above, but turns out that’s not really my main problem anymore. Actually I have two.
- There’s no standard Title or Content area (I only really need a Title as these posts will only have very specific, Piklist-created metaboxes)
- I can’t view an archive of the custom posts.
So I created my new post type, for listing adaptive snow sports organizations, with this code:
https://gist.github.com/cosmocanuck/7966275
I also added a file called “adaptive-metabox.php” in my theme, and its custom metaboxes are showing up fine when I edit the new posts:
https://gist.github.com/cosmocanuck/7966513
First problem: no title box. Why is that? My understanding from web self-study was that it, and the content text area, are included by default, but I may be misunderstanding how it works, or how Piklist does things.
Second problem: can’t view archive.
I can view one of my new custom posts here:
http://(name-of-my-site)/e2s_adaptive/1552/
My understanding is, if I go here:
http://(name-of-my-site)/e2s_adaptive/
…I should see an archive of the e2s_adaptive category. But instead, I get a 404 error.
I duplicated the archive.php file as archive-e2s_adaptive.php in my theme, which was how I understood i could eventually control the display. But it seems to be ignored, along with the archive.php file which I thought would be the fallback anyway.
So, I’m a little baffled, though I admit I’m venturing out into the far edges of my WordPress knowledge.
Any pointers in the right direction would be most tremendously welcome.
Thanks!
adam
cosmocanuckMemberIt’s working, but…
When i publish my custom post for the first time, I get an error like this:
Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /home/adama3/public_html/development/escape2ski/wp-includes/wp-db.php on line 880
Warning: Cannot modify header information – headers already sent by (output started at /home/adama3/public_html/development/escape2ski/wp-includes/wp-db.php:880) in /home/adama3/public_html/development/escape2ski/wp-includes/pluggable.php on line 899
However, when I hit my “back” button and click Publish again… it works fine.
Is this something I’m doing wrong or perhaps a glitch of some sort within Piklist?
adam
-
AuthorPosts