I guess this is really a two part question.
Does TablePress have some way to support Schema data?
Or where would I hook / filter the Markups output to adjust and add the correct itemtype and itemprop to the correct tags. Love the plugin 🙂
Below is a example of what I am looking for.
<table class="zebra-striped"> <tbody> <tr> <th class="rank"> Rank </th> <th class="school"> School </th> <th class="faculty"> Full-time to Part-time Faculty </th> <th class="financial-aid"> Financial Aid Rate </th> <th class="acceptance"> Acceptance Rate </th> <th class="retention"> Retention Rate </th> <th class="graduation"> Graduation Rate </th> <th class="accredited"> Years Accredited </th> <th class="default"> Default Rate </th> <th class="jobs"> Job Placement Rate </th> </tr> <tr itemscope itemtype="http://schema.org/CollegeOrUniversity"> <td class="rank" itemprop="aggregateRating"> 1 </td> <td class="school" itemprop="name"> <a rel="nofollow" itemprop="url" href="http://www.tamu.edu">Texas A & M University</a> </td> <td class="faculty"> 22.71 to 1 </td> <td class="financial-aid"> 52% </td> <td class="acceptance"> 63% </td> <td class="retention"> 92% </td> <td class="graduation"> 81% </td> <td class="accredited"> 88 </td> <td class="default"> 5% </td> <td class="jobs"> NA </td> </tr> </tbody> </table>
thanks for your question, and sorry for the trouble.
No, sorry, TablePress does not yet have support for Schema data (mainly, because there’s no way to really enter it, at this time).
Your best chance would probably be to add this via the filters in the class-render.php file, like
I have some idea’s on how to handle this if I come up with a working plugin I will let you know.
Is there a easy way to hook into the edit table page and add my own meta box? Also if there is a extension that would be good to look at for a reference that would be awesome.
Thanks a ton
you could take a look at the Table Auto Update Extension from http://tablepress.org/extensions/table-auto-import/
That adds a meta box to the “Import” screen, by inheriting/extending from the original import view.
Awesome, I will look at that. I was thinking accomplishing this by two ways visually.
By adding a tab to the options menu called “Schema Data” or adding a meta box to the actual edit screen for the table called “Schema Data”.
I am thinking to the actual edit screen would be more useful.
Then I would figure out how many columns there are and create a text field for each column plus one “for the tr”.
The first field will handle the itemtype url:
<tr itemscope itemtype="http://schema.org/CollegeOrUniversity">
Then for each cell the text field would handle the itemprop:
<td class="school" itemprop="name">
I am thinking this would be the easiest visually to handle the front end information.
The I will just have to add a filter and add the information in those fields into the TR tag and TD tags of table.
I have started on this project TablePress Extension: Schema Data. I am hoping to have it finished by the end of the week. I would take any advise you have to give on anything regarding the project. After spending a few hours looking through TablePress and your extensions they are built rock solid and with a very high quality of coding standards. I am hoping that I can produce a extension that meets the same high standard of coding.
I am getting stuck on how to hook into the save function ( handle_post_action_edit ) and save the Schema Data preferably as a array to the tables options array. I could use your advice on this if you have a second.
Thanks for everything
great to see that you are making quick progress!
Now, saving the data is indeed tricky, and I should probably have thought about this earlier…
It might therefore actually be the best to “abuse” some table data.
For example, you could designate the first row of input fields as the Schema data. With that, you’d only have to make changes to the rendering functions (i.e. extract that data and add it to the table HTML as the new HTML markup, instead of having it printed as regular table cells).
With that approach, you’d get the input fields and the saving automatically, with the drawback that you would not have correct “labels” or naming on the Edit screen for this data.
Another idea might be to add the data via the Shortcode. You could for example define a new Shortcode parameter which has the Schema data as
|-separated string, like
[table id=123 schema_data="school|name|id" /]
I have most the code written “in a rough state”
I now have my fields $_POST ( https://www.dropbox.com/s/ihprw7gwn7jtrb1/Screenshot%202014-03-13%2016.52.51.png )
But I am truly not a expert with form data I tend to avoid forms. So I need to grab the data and save it. Once I have that completed. And I can pull the data from the database I just have to finish my filter by digging more into tablepress_cell_css_class and how it builds items. I been pushing all my changes to GitHub, even tho I am becoming pretty filmiure that last two days of TablePress. If you see a better way of doing something I will take your advice on it.
I would like to make the plugin available on TablePress so editing the JS is out. I also don’t feel comfortable messing with the table data incase something goes wrong I don’t want to risk people losing their tables. Since I am getting the Data to post now I just need to grab it and save it “Somewhere”. Once I have that figured out, I just need to finish the filter and this should be ready to test “crosses finger”
I have the plugin now saving and recalling the needed data properly, Now I just need to get a better handle on how to filter the tablepress_cell_css_class function to get the result we want. I could use any insight on this cause is seems to be a very complicated mesh of code. I am hoping to have a rough working version by the end of Friday so I can clean it up and test all weekend. Thanks again for all your help.
I haven’t yet had chance to take a more detailed look at your code, but I’m very interested in seeing how you now save the data, and actually how you submit the form without making changes to the JS. Back in my head, I have feeling that this might not be possible without risking to lose modifications to the table data that were not yet saved (i.e. the case where a user edits the table and the Schema data at the same time, but then uses the submit method that you added), but we’ll see.
I saw that you submitted a pull request for new filters for the HTML output. After taking a look at that, I can see that those will indeed be necessary. The existing
tablepress_cell_css_classfilters (and related) are indeed not sufficient here.
I’ll be waiting for you to complete that PR then and then gladly add those filters!
Well I have the rough code completed and working.
I am just hung up on one item, I am moving the code to its own render class to extend class-render.php and TablePress_Render with my own render class. I just can’t seem to find the best way to Initialized my class with yours. Without hooking into three separate functions where they are calling it. Any suggestions what would be the best way to extend TablePress_Render?
I guess the simplest approach would be to hook into
tablepress_render_datawhich gets the entire table array as a parameter. From that, you can extract the
$table['id']and use that to load the Schema data (from wherever you have stored it), and then append that to the
$tablearray, e.g. as
As the filters for the actual rendering (those that we still have to add) will also get the entire
$tablearray, they would again have access to the Schema data and can generate the HTML.
With that, you wouldn’t have to create a child class of the render class, but use plain filter hooks.
- The topic ‘Schema Data Support’ is closed to new replies.