Title: Dynamic content
Last modified: April 5, 2018

---

# Dynamic content

 *  Resolved [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/)
 * If you look at the page above, you will see there is a very small table that 
   describes the attributes of a fern cultivar. I was thinking of creating a table
   for each particular cultivar but there may be 100s of them. Another approach 
   would be to have one dynamic table that could insert the content from an external
   file. Is it possible to change the short code to include a parameter that would
   be the index to the external file, something like [table id=145 key=”xxx” /].
   Or is there a better way of doing this?
    I have written some filters that manipulate
   the content in a tablepress table
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fdynamic-content-16%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/dynamic-content-16/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/dynamic-content-16/page/2/?output_format=md)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10149682)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * Your best chance for this should be to use the TablePress Extension from [https://tablepress.org/extensions/row-filter/](https://tablepress.org/extensions/row-filter/)
 * You’d then have to put all data in one big table, where each row resembles one
   fern cultivar. (The labels that you have in the first column right now would 
   be the column headings.)
    Using the Extension you could then filter the table
   to include just the desired entry.
 * Then, to again get the data displayed as a column and not a row, you could use
   the `flip` mode of the Extension from [https://tablepress.org/extensions/responsive-tables/](https://tablepress.org/extensions/responsive-tables/)
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10150587)
 * Thanks
    I got the row-filtering to work but not the flip This is my code: [table
   id=152 filter=”Athyrium filix-femina&&Moulzie Burn” responsive=flip responsive_breakpoint
   =all/] and this is the [page](https://ebps.org.uk/ferns/growing/fern-cultivars/athyrium-filix-femina/corymbiferum-2/)
   I now have TablePress Version 1.9 TablePress Extension: Responsive Tables Version
   1.4 TablePress Extension: Row Filtering Version 1.3
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10150714)
 * Urgh – forgive me – I did not activate the responsive plugin!
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10150752)
 * But I do have a problem with this
    I don’t want it to scroll Is it possible to
   switch the scroll off and show the full contents of the table over several lines?
   see [here ](https://ebps.org.uk/ferns/growing/fern-cultivars/athyrium-filix-femina/corymbiferum-2/)
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10151194)
 * Hi,
 * we could turn off the scrolling and show the content in multiple lines, but unfortunately,
   this will mean that the row heights have to be adjusted manually 🙁
 * You could e.g. use this “Custom CSS”:
 *     ```
       .tablepress-id-152.tablepress-responsive-all tbody {
       	overflow: visible;
       }
       .tablepress-id-152.tablepress-responsive-all thead th,
       .tablepress-id-152.tablepress-responsive-all tbody td {
       	white-space: normal;
       	line-height: normal;
       	height: 68px;
       }
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10151411)
 * Not so useful – have a look!
 * At the bottom of the page I have created a new table 153 which I can populate
   from an external file using the filter and it works. The only bit I cannot do
   is send the “key” to the filter
    Is it possible for you to address that problem,
   because it seems to me an easier solution then using your additional plugins 
   and having to transpose the tables and craft CSS to cater for different row heights
 * This is the code
 *     ```
       //***Custom TablePress table 153**/
       add_filter( 'tablepress_cell_content', 'table153', 10, 4 );
       function table153( $tablepress_cell_content, $table_id, $row_number, $column_number )
           {
           if ($table_id!=153)
              {
               return $tablepress_cell_content;
              }
       $key="'Trippitt's Crested'";
       $title="Cultivar name:";
       $header= "Header";
       $end="End";
       $dir = "CultivarList.csv";
       $delims = ",%#,";
       $fp = fopen('https://ebps.org.uk/php/CultivarList.csv', "r") or die ("could not open file");
       $y=0;
       	while (!feof($fp)) 
       	{
       	$line = fgets($fp, 1024);
       	$Column1 = strtok($line, $delims);
       	$Column2 = strtok($delims);
       	$Column2=trim($Column2);
       	if ($Column1 == $header){continue;}
       	if ($Column1 == $title)
                  {
                    if ($Column2==$key)
                           {
   
                            $y=1;
                           } 
                  }
                if ($y)
                   {
                    if ($Column1 == $end){break;}
                    if ($column_number==1 and $row_number==$y)
                       {
                       $tablepress_cell_content =$Column1;
                       return $tablepress_cell_content;
                       }
                    if ($column_number==2 and $row_number==$y)
                       {
                       $tablepress_cell_content =$Column2;
                       return $tablepress_cell_content;
                       }
                    $y++;
                   }
              }
       }
       ```
   
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10151442)
 * Hi,
 * the row height CSS is only necessary because of how the `flip` mode works.
 * I’m not sure that your approach of opening and parsing a CSV (with an HTTP request!)
   for every table cell is a good idea.
 * How about we try to find a different solution for flipping? We don’t really have
   to do it in CSS, you could use a filter hook (like `tablepress_table_render_data`)
   for that as well, and then flip the table/array in PHP. With that, you would 
   get the data printed as a column (without having to use the `flip` mode or other
   CSS), while maintaining the data would be done in rows.
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10151524)
 * The trouble with me is that I don’t really understand the implications of what
   I am doing
    You would have to help me a bit more to understand what you mean 
   in your third paragraph I found the code on Github but it is too advanced for
   me to understand By the way I am 66 years old, entirely self taught…
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10151565)
 * Hi Andrew,
 * okay, I looked into this a bit and found this neat way:
 *     ```
       add_filter( 'tablepress_table_render_data', 'tablepress_transpose_table', 10, 3 );
       function tablepress_transpose_table( $table, $orig_table, $render_options ) {
         if ( '153' !== $table_id ) {
           return $table;
         }
   
         // Transpose the data array.
         array_unshift( $table['data'], null );
         $table['data'] = call_user_func_array( 'array_map', $table['data'] );
   
         return $table;
       }
       ```
   
 * This PHP code will flip table 153 in PHP, so that you won’t have to use the `
   flip` mode of the Responsive Tables Extension, nor any CSS for row heights.
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10151782)
 * I put this code in functions.php
    I changed 153 to 152 (153 was an empty table)
   But it does not seem to work Have I misunderstood something or is it a cacheing
   problem?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10152635)
 * Hi,
 * this could indeed be a caching problem, as the function will only be called again
   once the cached tables are refreshed (every 24 hours).
    You could force that 
   by simply making and reversing a dummy change to the table and saving that. This
   will also flush the cache.
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10152707)
 * You can see, under “Cultivar Group” I inserted “Change to flush the cache” but
   to no avail
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10152733)
 * Hi,
 * ah, small mistake in the code…
    Please replace
 *     ```
       if ( '152' !== $table_id ) {
       ```
   
 * with
 *     ```
       if ( '152' !== $table['id'] ) {
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [Andrew Leonard](https://wordpress.org/support/users/andrewleonard/)
 * (@andrewleonard)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10152834)
 * Yeeeees!
    Thank you as ever, most excellent support If my people like this I 
   will see if I can donate to you, wee have done it before
 * One more tiny thing – the first line (heading line?) is upper-case, bold – can
   we remove that to make it look like the rest of the table?
    (see table 145 above
   for styling)
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/#post-10152875)
 * Hi,
 * thanks for wanting to donate, I really appreciate it!
 * Now, for that heading row: We’ll need to get a bit creative here, so that we 
   still get the data of the header row, but not its styling.
    Can you try this 
   modified Shortcode, please (with FILTER being your filter term)?
 *     ```
       [table id=152 filter="FILTER||Cultivar Name" table_head=false first_column_th=true /]
       ```
   
 * (The extra parameters will make the first column the header, while the extra “
   Cultivar Name” in the filter will cause the first row still being displayed, 
   even though it’s no longer the header row.)
 * Regards,
    Tobias

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/dynamic-content-16/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/dynamic-content-16/page/2/?output_format=md)

The topic ‘Dynamic content’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

 * 21 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [8 years, 1 month ago](https://wordpress.org/support/topic/dynamic-content-16/page/2/#post-10153842)
 * Status: resolved