Category Archives: Table

– Welcome –

 

Welcome to WordPress-Saratoga

  • Attendance: / Sign-in Sheet / password
  • Survey 1: Macintosh, Windows, Linux?
  • Survey 2: Freelance, Startup Team Member, Corporate Employee?
  • Survey 3: Beginner, Intermediate, Advanced User?
  • Fundamentals
    • Blogging
      • Write & post, categorize & tag; fresh content, from time to time.
      • Content consists of text, photos, and/or audio/visual media.
      • Accept comments from visitors.
    • WordPress.com
      • Free Hosted Service, Themes, and Widgets (limited)
      • Optimized Resource Utilization, Load Balancing
      • Automatic Version Updating
    • WordPress.org
      • Host a CMS* website on server of own choosing.
      • Unlimited Customization, Access to Code
      • Maintenance is your own Responsibility!
  • This Month’s Question?
  • Introduce Yourself
    • Name, Title, and Background
    • Tell us about your experience with WordPress so far.
    • Where do you plan to go with WordPress?
  • Next Month’s Topic?

 <- Twitter Site

* Content Management System (CMS) is a computer program that allows publishing, editing and modifying content on a website as well as maintenance from a central interface. Such systems provide procedures to manage workflow in a collaborative environment.



Cupertino WordPress Meetup

Cupertino, CA
76 Members

We’re a group of local WordPress developers, designers, and publishers who get together to share our knowledge and experience, and to meet other WordPress users in the area. T…

Next Meetup

Improving WordPress Search: Help your readers find the conte…

Thursday, May 16, 2019, 6:30 PM
5 Attending

Check out this Meetup Group →

The San Jose WordPress Meetup

San Jose, CA
596 Members

We’re a group of WordPress enthusiasts located in San Jose, CA. We are a mix of designers, developers, and small business owners who work with WordPress and love to share our …

Next Meetup

Improving WordPress Search: Help your readers find the conte…

Tuesday, May 7, 2019, 5:30 PM
13 Attending

Check out this Meetup Group →

WordPress Bay Area Foothills Group

Milpitas, CA
522 Geeks

If you love to design and build blogs and CMS sites with WordPress this is the group for you. Down and dirty technical talk about WordPress php and CSS – Themes and plugins. L…

Next Meetup

Building a Membership Site Using Free WordPress Plugins

Wednesday, May 29, 2019, 1:00 PM
2 Attending

Check out this Meetup Group →

WordPress-Saratoga

Saratoga, CA
16 WordPressers

WordPress is an open source content management tool and internet publishing platform powered by PHP & MySQL.This MeetUp group gives presentations and holds discussions about …

Next Meetup

Themes, Plugins, & Templates

Thursday, May 16, 2019, 1:15 PM
7 Attending

Check out this Meetup Group →

rocketlaunch.live

1) Table Block

New Post, Add Block, Create.

Look under Formatting to find the Gutenberg block for Table.

If you know the number of rows and columns, and want to fill in each data cell manually, then this will work for you.

Table code is displayed when you “Edit as HTML”
Copy this HTML text to use later in a plugin
Update and View Post

NEXT: We’ll paste the HTML code into a plugin, and create the exact same table in your test post by using a shortcode.

2) Shortcode

Edit your test post to run a plugin. Find the Shortcode block under Widgets.

Add the shortcode API and then Update your test post.

Go to the Plugin Editor. We’re going to cannibalize the Hello Dolly plugin that comes as default with every installation.

Delete everything except the Plugin Name, and change that to “My Table”.
Create the shortcode’s function after the add_shortcode function.
Paste the HTML text string as the function’s return value.
Activate the My Table plugin. * **
Refresh the test post.
Notice that the two tables are identical.

* The reference to “a new version of My Table” is actually a reference to Hello Dolly, somehow remembered by core. If you click “update now”, all the code for the Hello Dolly plugin will revert back.

** Note: It is possible to modify and update the plugin code while it is active, and still get the shortcode in the post to display as you’d expect. But, sometimes you’ll get an error. If that happens, open another window, deactivate the plugin, then go back and update the code.


For your future reading pleasure:

https://codex.wordpress.org/Function_Reference/add_shortcode

https://developer.wordpress.org/plugins/shortcodes/basic-shortcodes

https://codex.wordpress.org/Shortcode_API

3) For Loop

You can copy & paste in order to add rows, if you want.

But, it might be better done programmatically using a loop.

Play with using variable values within the loop.

Notice that the HTML string is broken up and string concatenation operations are performed with a dot equals sign.

Use a “for” loop if you know in advance exactly how many rows are needed.

Update the plugin code and refresh the post.

9) Copy & Paste

<?php
/*
Plugin Name: My Table
*/
add_shortcode( 'mytable', 'myTableFun' );

function myTableFun( $atts ) {
    $a = shortcode_atts( 
        array(
            'cost' => '',
            'fee' => ''
            ), $atts 
        );
    $c = $a['cost'];
    $f = $a['fee'];

    $h = "<table id='rowfocus'>";

    $h .= "<caption>WordPress-Saratoga</caption>";

    $h .= "<tr><th>Number of Members</th>";

    $h .= "<th>Annual Fee</th></tr>";

    do {              
        $i++; $q = $c/$i;         
        $h .= "<tr><td>" . $i . "</td>";         
        $h .= "<td>" . "$";              
        $h .=  number_format($q,2);         
        $h .= "</td></tr>";         
        } while ($q > $f); 

    $h .= "</table>";      
    return $h;      
    }
th, td {text-align:right;}

th {
     background-color:green;
     color:white;
     }

rowfocus tr:hover {

background-color:#ddd; }

caption {font-size: 22px;text-align: center;}