• Resolved mjs111

    (@mjs111)


    I’m new here and just installed the Google inline spreadsheet viewer for WordPress. I was referred here for help. I’d like to add zebra striping using the short codes but haven’t figured out the right syntax yet. Right now my short code line looks something like this:

    [gdoc key=”ABCDEFG” datatables_page_length=”25″]

    I want to add to this short code line the datatables_stripeClasses option, with two elements in the array for alternating stripes. I’ve tried a few guesses at the syntax but haven’t succeeded yet.

    I tried the datatables.net forum but didn’t get any responses. I’m not sure if that’s the best place for gdoc-specific short code syntax though.

    Thanks for any help! By the way, this plugin is great. I tried making a donation but the PayPal link was bad. When the link works I’m happy to donate for the great work on this.

    Mike

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mjs111

    (@mjs111)

    PayPal link works now. Sent you donation for the awesome work.

    Thanks!

    Mike

    Plugin Author Meitar

    (@meitar)

    Thanks for the donation. ??

    You may want to take a closer look at the Other Notes page. The shortcode attributes for the DataTables API use underscore-separated syntax. This means datatables_stripeClasses should be changed to datatables_stripe_classes. That might be why the plugin is not recognizing this option for you.

    Thread Starter mjs111

    (@mjs111)

    Thanks, Meitar!

    I’m still getting up to speed on the gdoc syntax for the arguments. The docs on the web for datatables gives you what you need if you’re writing javascript but I think I’m still screwing up syntax-wise when transferring that to the gdoc short codes. I tried this:

    [gdoc key=”ABCDEFG” datatables_page_length=”25″ datatables_stripe_classes=”strip1 strip2″]

    but no luck. I also tried some variations like no arguments (thinking maybe there was a two stripe default), a comma between array entries, and a single integer to see if that would specify the number of array entries but no luck yet.

    Plugin Author Meitar

    (@meitar)

    The docs on the web for datatables gives you what you need if you’re writing javascript but I think I’m still screwing up syntax-wise when transferring that to the gdoc short codes.

    Actually, the shortcode syntax also uses JavaScript in its value. The gotcha is that with arrays in JavaScript use the square bracket character ([ and ]), which is also what WordPress uses to denote the start and end of a shortcode itself. You need to URL-encode these in the shortcode value so WordPress doesn’t get confused and think you’re done writing your shortcode. This is mentioned in this plugin’s FAQ, have another read of that.

    The example code on the DataTables reference manual says:

    $('#example').dataTable( {
      "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
    } );

    so I would expect a shortcode like this to be equivalent:

    
    [gdoc key="" datatables_stripe_classes='%5B"strip1", "strip2", "strip3"%5D']
    
    • This reply was modified 8 years, 3 months ago by Meitar. Reason: fixed copy-paste error
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Zebra Stripe Short Code Syntax’ is closed to new replies.