Difference between revisions of "Timeline Express Pro Modifications"

Wiki.TerraBase.info
Jump to navigation Jump to search
m
m
Line 80: Line 80:
OK, that solves the SEO issue because the sitemap now recognizes all the individual items and images because they also have their own individual URLs and "slugs".  And what is displayed to users is same as before with no changes.  But unfortunately the above "fix(es)" breaks the "Sources & Additional Information" link as it takes users to the full URL of the "announcement".  The citations are in the Excerpts Add-On section.  It's still easy to edit, with both the "announcement" and "excerpt" (AKA citations and references in my case), but now there needs to be a way to display the citations and references.
OK, that solves the SEO issue because the sitemap now recognizes all the individual items and images because they also have their own individual URLs and "slugs".  And what is displayed to users is same as before with no changes.  But unfortunately the above "fix(es)" breaks the "Sources & Additional Information" link as it takes users to the full URL of the "announcement".  The citations are in the Excerpts Add-On section.  It's still easy to edit, with both the "announcement" and "excerpt" (AKA citations and references in my case), but now there needs to be a way to display the citations and references.


== Fixing the Citations and References Link ==
==Fixing the Citations and References Link==
Ideally it would be great to have a modal popup dialogue that displays the Citations and References.  This involves extracting the information from the postmeta table and displaying it in a popup.  That's the easy part.  Getting the data in the postmeta table to display properly was a problematic issue.  The main issue stems from the fact there is HTML and ShortCode in postmeta table.  It needs to be displayed as raw output from WordPress, not as text in a paragraph.
Ideally it would be great to have a modal popup dialogue that displays the Citations and References, which involves extracting the information from the postmeta table and displaying it in a popup.  That's the easy part.  Getting the data in the postmeta table to display properly was a problematic issue.  The main issue stems from the fact there is HTML and ShortCode in postmeta table.  It needs to be displayed as raw output from WordPress, not as text in a paragraph.





Revision as of 17:50, 7 February 2020

Timeline Express Pro is a WordPress Plugin that presents information in a timeline format. They refer to the individual timeline items as "announcements", which are similar to post or pages. By default, instead of displaying the full content of the "announcement" it displays an automatically generated "excerpt" (abbreviated version). By default this excerpt does not contain any HTML or ShortCode (only plain text). For people that do wish to display HTML in the "excerpts" they created an Add-On (Timeline Express HTML Excerpt Add On) that displays a custom "excerpt" of the timeline post which can include HTML content and ShortCode. Unfortunately this is a manual process. IE, the "excerpt" must be created and maintained separately from the main announcement.

That's the way it functions, and I used the features as they were to do something slightly different than what they had envisioned for their software. I used the custom "excerpt" as the main content of my timeline. I did this because I realized I could make each "announcement" its own self-contained webpage. And it worked great. But it also left another feature unneeded. That feature was the ability to display the full announcement. That wasn't something I needed because I was already displaying the full "announcement" with the Excerpt Add-On.

But then I came up with a use for it. The website I was developing was a biography site that required sources to be cited. I changed the name of the link at the bottom of each timeline item to "Sources & Additional Information". The result was I could write the main content in the Excerpt Add-On section and do the citations in the "attachment" section, all on one screen. Perfect. Convenient and it displayed everything just like I wanted it to be.

Everything was perfect until it came to SEO (Search Engine Optimization) that is. The SEO Plugin I was using only provided a sitemap for the full "announcement", not the content of the Excerpt Add-On. That meant only the reference sections were cataloged by search engines, not the content that was displayed to users. I thought I could work around it by having the SEO Plugin create sitemaps for each of the webpages the timelines were on. That didn't work either because the SEO software couldn't "see" the individual items on a timeline. So a page containing several dozen images resulted in a sitemap that had ZERO images. Crap!

How to fix this?


The Fix(es)

The first thing that needed to be done was to swap everything in the "announcement" section with the content in the Excerpt Add-On section. I wasn't about to do a copy past on that for several hundred entries. The solution to that was to swap column data in two database tables with each other. But as I read, mySQL (MariaDB) doesn't have that capability like other database servers do. for mySQL, it has to be done in stages. I read a bunch of stuff from people who were experts in SQL server. For my purposes it was way to complex. To stay within my abilities, I decided to create a couple of temporary tables and copy the data to them, and then copy from the temporary tables to the places I wanted to put the data. To make things even easier, I used phpMyAdmin.

"Swap" Table Data in the WordPress Database

  • First, backup the database: Select Database in phpMyAdmin, Export Tab, use defaults, Go and save to a location
  • During the above step I noticed that the database had the incorrect collation defined, so I changed it to the WordPress recommended utf8mb4_unicode_ci setting: Select Database in phpMyAdmin, Operations Tab, Collation Section
  • Create two temporary tables, TT1 and TT2 (as in Temporary Table 1 and 2): Select Database in phpMyAdmin, immediately under it select New, and create three columns with the following settings
    • TT1 (duplicating the necessary columns from the WordPress postmeta table);
      • Name: post_id, Type: bigint, Length/Values: 20
      • Name: meta_key, Type: varchar, Length/Values: 255
      • Name: meta_value, Type: longtext, , Length/Values: Leave it Blank
      • Save it
      • Create an Index on Column 1: Go, Index Choice: PRIMARY
    • TT2 (duplicating the necessary columns from the WordPress posts table);
      • Name: ID, Type: bigint, Length/Values: 20
      • Name: post_type, Type: varchar, Length/Values: 20
      • Name: post_content, Type: longtext, Length/Values: Leave it Blank
      • Save it
      • Create an Index on Column 1: Go, Index Choice: PRIMARY
  • Use a SQL statement to copy the data from the postmeta Table to TT1 Table: Select Database in phpMyAdmin, SQL Tab, Go, with the following SQL statement;
INSERT INTO TT1 (post_id, meta_key, meta_value)
SELECT post_id, meta_key, meta_value
FROM wp_postmeta
WHERE meta_key = 'announcement_custom_excerpt';
  • Use a SQL statement to copy the data from the posts Table to TT2 Table: Select Database in phpMyAdmin, SQL Tab, Go, with the following SQL statement;
INSERT INTO TT2(ID, post_content, post_type)
SELECT ID, post_content, post_type
FROM wp_posts
WHERE post_type = 'te_announcements';

(The number of rows copied into TT1 and TT2 should be the same)

  • Use a SQL statement to copy the data from the TT1 Table to the posts Table: Select Database in phpMyAdmin, SQL Tab, Go, with the following SQL statement;
UPDATE wp_posts INNER JOIN TT1
SET wp_posts.post_content = TT1.meta_value
WHERE TT1.post_id = wp_posts.ID;
  • Use a SQL statement to copy the data from the TT2 Table to the postmeta Table: Select Database in phpMyAdmin, SQL Tab, Go, with the following SQL statement;
UPDATE wp_postmeta INNER JOIN TT2
SET wp_postmeta.meta_value = TT2.post_content
WHERE TT2.ID = wp_postmeta.post_id AND wp_postmeta.meta_key = 'announcement_custom_excerpt';

Editing of Excerpt Add-On PHP Code

After hunting around in the PHP code for a couple of minutes I found the areas where I needed to make the change. The change was to have the Excerpt Add-On retrieve data from the post Table instead of the postmeta Table. Below is the original code from the ../wp-content/plugins/timeline-express-html-excerpt-add-on/timeline-express-html-exerpts-add-on.php File (with tabs and spacing removed);

public function replace_default_timeline_express_excerpt( $excerpt, $post_id ) {
// If the new custom excerpt is set, return it.
if ( get_post_meta( $post_id, 'announcement_custom_excerpt', true ) ) {
echo apply_filters( 'the_content', get_post_meta( $post_id, 'announcement_custom_excerpt', true ) );
return;
}
return $excerpt;
}

The line with: echo apply_filters( 'the_content', get_post_meta( $post_id, 'announcement_custom_excerpt', true ) ); was replaced with the below two lines of code;

$AlternateSourceOfContent = get_post ( $post = $post_id, $output = 'OBJECT', $filter = 'raw');
echo apply_filters( 'the_content', $AlternateSourceOfContent->post_content );

(The section of code on the first line to the right of the equal sign could have just been: get_post( $post_id ); but the above is the full syntax of the WordPress "get_post" function)

OK, that solves the SEO issue because the sitemap now recognizes all the individual items and images because they also have their own individual URLs and "slugs". And what is displayed to users is same as before with no changes. But unfortunately the above "fix(es)" breaks the "Sources & Additional Information" link as it takes users to the full URL of the "announcement". The citations are in the Excerpts Add-On section. It's still easy to edit, with both the "announcement" and "excerpt" (AKA citations and references in my case), but now there needs to be a way to display the citations and references.

Fixing the Citations and References Link

Ideally it would be great to have a modal popup dialogue that displays the Citations and References, which involves extracting the information from the postmeta table and displaying it in a popup. That's the easy part. Getting the data in the postmeta table to display properly was a problematic issue. The main issue stems from the fact there is HTML and ShortCode in postmeta table. It needs to be displayed as raw output from WordPress, not as text in a paragraph.