• Resolved klaszewski

    (@klaszewski)


    Hello. I am trying to achieve a simple food menu for our Kindergarten. I created table, imported data from excel, and used shortcode to show full table on the separate site. However, it would be nice to show current day menu as a simple table in the sidebar. Can You provide some pointers how to achieve that?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    How does the full table look like? Can you please post a link to the page with the table where this problem happens, so that I can take a direct look? Thanks!

    Regards,
    Tobias

    Thread Starter klaszewski

    (@klaszewski)

    To be honest, we plan a very simple table, right now is something like:
    https://p50.edu.pl/jadlospis/

    Right now, I installed Your extension that allows collapsing, and it displays in column as on the main page for test purpose.

    • This reply was modified 4 years, 10 months ago by klaszewski.
    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    ok, thanks! So you would need to only show one specific column per day.

    You could maybe use custom code like this, to create wrapping Shortcode that will then only show the first column and the current day’s column:

    add_shortcode( 'table_today', 'klaszewski_tablepress_today_shortcode' )
    function klaszewski_tablepress_today_shortcode() {
      $weekday = date( 'N' );
      if ( $weekday > 5 ) {
         // Don't show anything on the weekend.
         return '';
      }
      $column = $weekday + 1;
      $atts = array(
        'id' => '1',
        'hide_columns' => 'all',
        'show_columns' => "1,{$column}",
      );
      return tablepress_get_table( $atts );
    }

    You could put this into your theme’s “functions.php” file and then put the Shortcode [table_today /] into your sidebar.

    Regards,
    Tobias

    Thread Starter klaszewski

    (@klaszewski)

    Is there any way to pair it with collapsing without much coding?

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    I’m not sure how that should look like, but it should be not problem to use the TablePress Responsive Tables Extension with this. Just add

    'responsive' => 'collapse',
    

    after the line

    'show_columns' => "1,{$column}",
    

    Regards,
    Tobias

    Thread Starter klaszewski

    (@klaszewski)

    Thanks! This works great!

    Plugin Author Tobias B?thge

    (@tobiasbg)

    Hi,

    no problem, you are very welcome! ?? Good to hear that this helped!

    Best wishes,
    Tobias

    P.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Current date column in sidebar’ is closed to new replies.