Timeline Express Pro Modifications: Difference between revisions

mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 90: Line 90:
The easy way to move information and access information between pages or the server and browser is to append data to the end of a URL: https://WhatEverWebSite/WhatEverPage.php?WhatEverVariable=1234567890 and access it with GET.  But how can that be done.  Easy, just build it into the string passed to the client using PHP.
The easy way to move information and access information between pages or the server and browser is to append data to the end of a URL: https://WhatEverWebSite/WhatEverPage.php?WhatEverVariable=1234567890 and access it with GET.  But how can that be done.  Easy, just build it into the string passed to the client using PHP.


=== Do it with a GET Command ===
===Do it with a GET Command===
The below code is a modified version of code from the Timeline Express Web site and should be put in the site Theme's (or child theme's) functions.php file;<syntaxhighlight lang="text">
The below code is a modified version of code from the Timeline Express Web site and should be put in the site Theme's (or child theme's) functions.php file;<syntaxhighlight lang="text">
function generate_custom_read_more_link()
function generate_custom_read_more_link()
Line 106: Line 106:
</syntaxhighlight>
</syntaxhighlight>


=== Do it with a POST Command ===
===Do it with a POST Command===
But it is so ugly.  Why not pass the information via Headers instead?  Replace the echo command in the above code block with this one;<syntaxhighlight lang="text">
But it is so ugly.  Why not pass the information via Headers instead?  Replace the echo command in the above code block with this one;<syntaxhighlight lang="text">
echo '<a href="" class="WhatEverClassName" onclick="event.preventDefault(); navigate_to_this_url(' . $post_id_to_pass . '); return false;">WhatEverLinkName</a>';
echo '<a href="" class="WhatEverClassName" onclick="event.preventDefault(); navigate_to_this_url(' . $post_id_to_pass . '); return false;">WhatEverLinkName</a>';
Line 151: Line 151:
</syntaxhighlight>All of the odd \ (backslashes) in the $script_string code is the escape character for PHP.
</syntaxhighlight>All of the odd \ (backslashes) in the $script_string code is the escape character for PHP.


=== Forget the Above Methods and use a Lightbox ===
===Forget the Above Methods and use a Lightbox===
But either of the two methods opens a new webpage.  That seems a bit clunky.  Why not do something far more slick like a Popup?  Well, as mentioned above there are issues with that.  And also mentioned above is a better solution.  Use a lightbox.  After installing the Featherlight Lightbox, insert the below PHP code into the theme's (or child theme's) functions.php file;<syntaxhighlight lang="text">
But either of the two methods opens a new webpage.  That seems a bit clunky.  Why not do something far more slick like a Popup?  Well, as mentioned above there are issues with that.  And also mentioned above is a better solution.  Use a lightbox.  After installing the Featherlight Lightbox, insert the below PHP code into the theme's (or child theme's) functions.php file;<syntaxhighlight lang="text">
function generate_custom_read_more_link()
function generate_custom_read_more_link()
Line 168: Line 168:
</syntaxhighlight>
</syntaxhighlight>


And there's also one more item to configure when using the "lightbox" method.  A dedicated page (WhatEverURL) needs to be created for the lightbox to open, with any custom CSS associated with making pages render correctly in a theme.  And the below code needs to also be inserted into the functions.php file in order to only have the functionality run on the pages it is intended to run on;<syntaxhighlight lang="text">
// This If Function is TRUE if the requested Page is for the intended links
// When FALSE, the $CONTENT is simply returned as is with no changes
if ( basename(get_permalink()) == 'PageNameToCheck') // If the Page or Post name changes, it also needs to be changed in the link generated in the Timeline Express function above.
{


$post_id_from_post_header = $_POST['PostIdPassed'];
$post_id_from_get = $_GET['metapost_id'];


// This If Function is TRUE if the page was requested via a direct link or crawled by a robot.
if( is_null( $post_id_from_post_header ) )
{
$post_id_from_post_header = $post_id_from_get;
}


$content_of_custom_excerpt = get_post_meta( $post_id_from_post_header, 'announcement_custom_excerpt', true );


// This If Function is only TRUE if there is no announcement_custom_exerpt Field in the metapost Table for a post.
// When FALSE, an announcement_custom_exerpt Field in the metapost Table for a post exists.
if( is_null( $content_of_custom_excerpt ) )
{
$custom_excerpt_result_message = 'This post has no custom excerpt associated with it.';
$content = $content;
return $content;
}
else{
$content = 'Post ID from GET:' . $post_id_from_get . '<br><br>' . 'Post ID from HEADER:' . $post_id_from_post_header . $content_of_custom_excerpt;
return $content;
}
}


else{
$content = $content;
return $content;
    }


 
}
 
add_filter ('the_content', 'display_sources_and_additional_information');
 
</syntaxhighlight>
 
 


<br />
<br />