Hide rows that contain inactive shortcode
-
Hello Tobias,
I have a unique need, I created a website where manufacturers can add their products and their specifications by using a Frontend forum, I can present the data form the form inside the table by using shortcodes for every field, now I wanted to upgrade my forums, so I created responsive forum that shows specs fields according to product type, and want to create one long table that have all the fields but SHOWS only rows that have activated shortcode in their cell submitted from the forum.
So, I want to create a specification table for the products that hides rows contain empty cells after loading the table.
Can you help me how to add this function to Tablepress? Because I used filter extension but it filters cells before the table load (filter the shortcodes itself)Screenshots
https://prntscr.com/qrov33
https://prntscr.com/qrouwaThanks in advance
-
This topic was modified 6 years, 4 months ago by
nourmustafa.
-
This topic was modified 6 years, 4 months ago by
-
Hi,
thanks for your post, and sorry for the trouble.
I think I understand what you mean, but unfortunately, I don’t really see a good way to achieve this.
The best that I can think of would be to modify the TablePress Row Filter Extension to parse Shortcodes already once before the filtering. Then, instead of returning an empty value in your custom Shortcode, that should return some “keyword”. You can then filter out all rows that do not contain that keyword and only show those, via thefilter_inverseShortcode parameter of the Row Filter Extension.Regards,
TobiasHi thanks For your reply,
I managed to make the default value of the cell to be “empty”, but when I use [table id=4 filter=”empty” filter_inverse=true /], rows contain “empty” word remain appearance!is there a way I can make TablePress Row Filter Extension to parse Shortcodes already once before the filtering as you suggested ?
I don’t have much knowledge of coding, so at least if you can give me an example to how to do that? And where to put the codes?Thanks in advance
Hi,
right now, this is expected, because your Shortcodes are evaluated after filtering.
You could try running the Shortcodes earlier. For that, change the line 169 of the Extension’s PHP file from$found = array();to
// Run Shortcodes early. foreach ( $row as &$cell_content ) { $cell_content = do_shortcode( $cell_content ); } unset( $cell_content ); $found = array();Regards,
TobiasThank you very much, that solve it completely
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Best wishes,
TobiasP.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!
Hello Tobias,
Is there away enable me to filter empty rows after the shortcode executed? Because I had a bug in the forum plugin, and some fields don’t generate a default value.
Thanks in advance
Hi,
I’m really sorry, but I don’t know a way for that 🙁 Filtering for actual empty values is not possible, because those are “everywhere” (even “inside” other values).
Regards,
TobiasHi,
Can it somehow integrated with “filter_full_cell_match=true”? so filter completely empty cells only.
Regards,
Nour MustafaHi,
that could be an approach, but the problem is that there’s a check in the PHP code:
// Early exit, if no or an empty "filter" parameter is given. if ( empty( $render_options['filter'] ) ) { return $table; }This also includes empty text… You could however try to modify the default values:
Change line 54 to$default_atts['filter'] = false;and line 99 to
if ( false === $render_options['filter'] ) {After that, an empty filter term in the Shortcode (
filter=""andfilter_full_cell_match=true) should be possible. I haven’t tested this though.Regards,
TobiasHi,
thank you for your reply, I will give it a try and update you soon.
Hope it works,
best regards
Hi Tobias,
It works great, but one thing, if you add a modification to the text like make it bold ar something like that , the filter won’t work.
anyway thank you very much, now I can run my website smoothly.Best regards
Nour Mustafa-
This reply was modified 6 years, 4 months ago by
nourmustafa.
-
This reply was modified 6 years, 4 months ago by
nourmustafa.
Hi,
Good to hear that this helped!
You would need to use CSS code then, for the styling, like https://tablepress.org/faq/highlight-cells-or-content/
Best wishes,
TobiasP.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!
-
This reply was modified 6 years, 4 months ago by
The topic ‘Hide rows that contain inactive shortcode’ is closed to new replies.