Hi,
nice hack, thanks for sharing it! π
Doing this in jQuery should not be hard though. You don’t really need to worry about the jQuery code in WP-Table Reloaded, you would just need to add your own code to the page footer.
A simple way for that is the “HiFi” plugin, or you could use one of the other WP-Table Reloaded filter hooks (of which I don’t know the name right now).
Regards,
Tobias
How do you choose which tabel and row it’s added to?
Hi,
from how I understand bitkahuana’s code, you have to do this manually in the function, by checking the variables $table_id
and $row_idx
for the desired values.
A JS solution based on jQuery could use the available CSS selectors for this.
Regards,
Tobias
It wont work for me, all the rows just get clickable.
Can you please give an example with e.g. table id 1 and row 3?
Hi,
sure:
function wp_table_reloaded_hack_row( $row_class, $table_id, $row_idx ) {
if ( 1 != $table_id )
return $row_class;
if ( 3 != $row_idx )
return $row_class;
$row_class .= "\" onclick=\"window.location = '/your-link-here'";
return $row_class;
}
add_filter( 'wp_table_reloaded_row_css_class', 'wp_table_reloaded_hack_row', 10, 3);
Regards,
Tobias
sorry, been unavailable to respond until now.
Tobias, thanks for handling this!!!
What I’d LOVE to see though is an example of how to do it with jQuery. I’m pretty js literate and have done some jQuery, but I can’t figure out what to add to add functionality like this to your plugin (hence the hack).
Hi,
no problem, bitkahuana π
In jQuery, you could simply use something like this (for table 1 and row 3 here):
<script type="text/javascript">
jQuery(document).ready(function($){
$('.wp-table-reloaded-id-1 .row-3').click(function() {
window.location = 'http://www.example.com/';
});
});
</script>
This just needs to be added to the page footer, e.g. with the HiFi plugin.
(Note: I did not test this, but that’s the way it should work.)
Regards,
Tobias
Mr. Noob here I’m afraid… but can you please post an example of how to make 2 or more rows clickable and both linking to different pages?
Making all rows or a single row clickable works for me now, but 3 rows with 3 different links I can’t get the hang off.
Hi,
which of the row click solutions are you trying to use? Can you post the link to the pages/tables that you are experimenting with?
Regards,
Tobias
Hi, thank you for your quick reply. My site is in Maintenance Mode as it has not been launched, so I can not link to it yet.
I am trying to use bitkahuna’s code with your example edit for row 3.
function wp_table_reloaded_hack_row( $row_class, $table_id, $row_idx ) {
if ( 1 != $table_id )
return $row_class;
if ( 3 != $row_idx )
return $row_class;
$row_class .= "\" onclick=\"window.location = '/your-link-here'";
return $row_class;
}
add_filter( 'wp_table_reloaded_row_css_class', 'wp_table_reloaded_hack_row', 10, 3);
Now I would like to make each row clickable and linking to a different page. I’m sure it’s pretty basic, but like I said, I am an absolute beginner but would love to get this to work as I’ve always loved clickable rows π
Hi,
thanks for the details. Then just extend the code like this:
function wp_table_reloaded_hack_row( $row_class, $table_id, $row_idx ) {
if ( 1 != $table_id )
return $row_class;
if ( 3 == $row_idx )
$row_class .= "\" onclick=\"window.location = '/your-link-for-row-3-here'";
else if ( 4 == $row_idx )
$row_class .= "\" onclick=\"window.location = '/your-link-for-row-4-here'";
else if ( 7 == $row_idx )
$row_class .= "\" onclick=\"window.location = '/your-link-for-row-7-here'";
return $row_class;
}
add_filter( 'wp_table_reloaded_row_css_class', 'wp_table_reloaded_hack_row', 10, 3);
Regards,
Tobias
Thats really great, thanks!
Hi,
awesome! Thanks for the confirmation, that this will work for you π
Best wishes,
Tobias
ha, glad i’m getting notifications still on this thread and seeing the hack still being put to use! your plug-in is really awesome.
Hi,
yes, that’s definitely a nice feature π
And thanks for the nice words about the plugin!
Best wishes,
Tobias