Skip to content

Commit

Permalink
Moved Article Blocks to so they can be cached with the rest of the ar…
Browse files Browse the repository at this point in the history
…ticle

Speed up article by adding the blocks "You Might Also Like", "What's Related", and "Article Options" to article cache. Trackbacks also added as well.

You Might Also Like article block now renders the same way as the other blocks (removed hard coded HTML
  • Loading branch information
eSilverStrike committed Mar 25, 2020
1 parent 137b1c0 commit a88b07f
Show file tree
Hide file tree
Showing 20 changed files with 246 additions and 148 deletions.
69 changes: 7 additions & 62 deletions public_html/article.php
Expand Up @@ -419,12 +419,6 @@ function extractExternalLinks($text) {

$articleTemplate = COM_newTemplate(CTL_core_templatePath($_CONF['path_layout'] . 'article'));

// Render article near top so it can use mode if set (ie to figure out page break)
// Another option here could be to figure out if story is first on page
$tmpl = $_CONF['showfirstasfeatured'] ? 'featuredarticletext.thtml' : '';
$articleTemplate->set_var('formatted_article',
STORY_renderArticle($article, 'n', $tmpl, $query, $articlePage));

// Pass Page and Comment Display info to template in case it wants to display anything else with comments
$articleTemplate->set_var('page_number', $articlePage);
$articleTemplate->set_var('page_total', $page_break_count);
Expand All @@ -435,7 +429,7 @@ function extractExternalLinks($text) {

$articleTemplate->set_var('story_id', $article->getSid());
$articleTemplate->set_var('story_title', $pagetitle);
$story_options = array();
$story_options = [];
if (($_CONF['hideemailicon'] == 0) && (!COM_isAnonUser() ||
(($_CONF['loginrequired'] == 0) &&
($_CONF['emailstoryloginrequired'] == 0)))
Expand Down Expand Up @@ -499,37 +493,12 @@ function extractExternalLinks($text) {
$url);
}
}
/*
if (true) { // can subscribe
$commentSubscribeURL = '';
$story_options[] = COM_createLink('Nubbies', $commentSubscribeURL, array('rel' => 'nofollow'));
$story_template->set_var('comment_subscribe_url', $commentSubscribeURL);
$story_template->set_var('lang_comment_subscribe', 'Nubbies');
}
*/
$related = STORY_whatsRelated($article->displayElements('related'),
$article->displayElements('uid'),
$article->getSid());
if (!empty($related)) {
$related = COM_startBlock($LANG11[1], '',
COM_getBlockTemplate('whats_related_block', 'header'))
. $related
. COM_endBlock(COM_getBlockTemplate('whats_related_block',
'footer'));
}
if (count($story_options) > 0) {
$optionsblock = COM_startBlock($LANG11[4], '',
COM_getBlockTemplate('story_options_block', 'header'))
. COM_makeList($story_options, PLG_getThemeItem('article-css-list-options', 'article'))
. COM_endBlock(COM_getBlockTemplate('story_options_block',
'footer'));
} else {
$optionsblock = '';
}
$articleTemplate->set_var('whats_related', $related);
$articleTemplate->set_var('story_options', $optionsblock);
$articleTemplate->set_var('whats_related_story_options',
$related . $optionsblock);

// Render article near top so it can use mode if set (ie to figure out page break)
// Another option here could be to figure out if story is first on page
$tmpl = $_CONF['showfirstasfeatured'] ? 'featuredarticletext.thtml' : '';
$articleTemplate->set_var('formatted_article',
STORY_renderArticle($article, 'n', $tmpl, $query, $articlePage, 1, $story_options));

// Display the comments, if there are any ..
if (($article->displayElements('commentcode') >= 0) && $show_comments) {
Expand All @@ -538,31 +507,7 @@ function extractExternalLinks($text) {
CMT_userComments($article->getSid(), $article->displayElements('title'), 'article',
$commentOrder, $mode, 0, $commentPage, false, $delete_option, $article->displayElements('commentcode')));
}
if ($_CONF['trackback_enabled'] && ($article->displayElements('trackbackcode') >= 0) &&
$show_comments
) {
if (SEC_hasRights('story.ping')) {
if (($article->displayElements('draft_flag') == 0) &&
($article->displayElements('day') < time())
) {
$url = $_CONF['site_admin_url']
. '/trackback.php?mode=sendall&amp;id=' . $article->getSid();
$articleTemplate->set_var('send_trackback_link',
COM_createLink($LANG_TRB['send_trackback'], $url));
$articleTemplate->set_var('send_trackback_url', $url);
$articleTemplate->set_var('lang_send_trackback_text',
$LANG_TRB['send_trackback']);
}
}

$permalink = COM_buildUrl($_CONF['site_url']
. '/article.php?story=' . $article->getSid());
$articleTemplate->set_var('trackback',
TRB_renderTrackbackComments($article->getSID(), 'article',
$article->displayElements('title'), $permalink));
} else {
$articleTemplate->set_var('trackback', '');
}
$display .= $articleTemplate->finish($articleTemplate->parse('output', 'article'));

$breadcrumbs = TOPIC_breadcrumbs('article', $article->getSid());
Expand Down
26 changes: 22 additions & 4 deletions public_html/layout/denim/archivearticletext.thtml
Expand Up @@ -37,10 +37,28 @@
{!endif}
{!endif}

{!if related_articles_by_keyword}
<hr{xhtml}>
{related_articles_by_keyword}
{!endif}
<hr{xhtml}>
<div class="uk-margin uk-grid" data-uk-grid-margin data-uk-grid-match>
{!if related_articles_by_keyword}
<div class="uk-width-1-1">
{related_articles_by_keyword}
</div>
{!endif}

<div class="uk-width-medium-1-2">
{whats_related}
</div>

<div class="uk-width-medium-1-2">
{story_options}
</div>

{!if trackback}
<div class="uk-width-1-1">
{trackback}
</div>
{!endif}
</div>
{!endif}
{!if navi_list}
<ul class="story_navi">
Expand Down
14 changes: 0 additions & 14 deletions public_html/layout/denim/article/article.thtml
Expand Up @@ -6,20 +6,6 @@

{# page_number: current page number - page_total: total page count - comments_on_page: if comments will appear on page #}
{!if comments_on_page}
<div class="uk-grid uk-grid-margin" data-uk-grid-margin data-uk-grid-match>
<div class="uk-width-medium-1-2">
{whats_related}
</div>

<div class="uk-width-medium-1-2">
{story_options}
</div>

<div class="uk-width-1-1">
{trackback}
</div>
</div>

{commentbar}
{!endif}

Expand Down
26 changes: 22 additions & 4 deletions public_html/layout/denim/articletext.thtml
Expand Up @@ -37,10 +37,28 @@
{!endif}
{!endif}

{!if related_articles_by_keyword}
<hr{xhtml}>
{related_articles_by_keyword}
{!endif}
<hr{xhtml}>
<div class="uk-margin uk-grid" data-uk-grid-margin data-uk-grid-match>
{!if related_articles_by_keyword}
<div class="uk-width-1-1">
{related_articles_by_keyword}
</div>
{!endif}

<div class="uk-width-medium-1-2">
{whats_related}
</div>

<div class="uk-width-medium-1-2">
{story_options}
</div>

{!if trackback}
<div class="uk-width-1-1">
{trackback}
</div>
{!endif}
</div>
{!endif}
{!if navi_list}
<ul class="story_navi">
Expand Down
26 changes: 22 additions & 4 deletions public_html/layout/denim/featuredarticletext.thtml
Expand Up @@ -37,10 +37,28 @@
{!endif}
{!endif}

{!if related_articles_by_keyword}
<hr{xhtml}>
{related_articles_by_keyword}
{!endif}
<hr{xhtml}>
<div class="uk-margin uk-grid" data-uk-grid-margin data-uk-grid-match>
{!if related_articles_by_keyword}
<div class="uk-width-1-1">
{related_articles_by_keyword}
</div>
{!endif}

<div class="uk-width-medium-1-2">
{whats_related}
</div>

<div class="uk-width-medium-1-2">
{story_options}
</div>

{!if trackback}
<div class="uk-width-1-1">
{trackback}
</div>
{!endif}
</div>
{!endif}
{!if navi_list}
<ul class="story_navi">
Expand Down
2 changes: 2 additions & 0 deletions public_html/layout/denim/functions.php
Expand Up @@ -324,6 +324,7 @@ function theme_init_denim()
$_BLOCK_TEMPLATE['configmanager_block'] = 'blockheader-config.thtml,blockfooter-config.thtml';
$_BLOCK_TEMPLATE['configmanager_subblock'] = 'blockheader-config.thtml,blockfooter-config.thtml';
$_BLOCK_TEMPLATE['whats_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
$_BLOCK_TEMPLATE['articles_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
$_BLOCK_TEMPLATE['story_options_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';

// Define the blocks that are a list of links styled as an unordered list - using class="blocklist"
Expand Down Expand Up @@ -377,6 +378,7 @@ function theme_getThemeItem_denim($item)
case 'core-css-list-feed': // Return 1 or more CSS Classes - For RSS Feed Portal Block - replacing "list-feed"
case 'article-css-list-directory': // Return 1 or more CSS Classes - For Article Directory page - New item as of GL v2.2.1
case 'article-css-list-related': // Return 1 or more CSS Classes - For Article Page What's Related List - replacing 'list-whats-related'
case 'article-css-list-related-articles': // Return 1 or more CSS Classes - For Article Page You might also like
case 'article-css-list-older': // Return 1 or more CSS Classes - For Older Articles Block - replacing "list-older-stories"
case 'topic-css-list-related': // Return 1 or more CSS Classes - For Autotags Related Topic items list - New item as of GL v2.2.1

Expand Down
2 changes: 2 additions & 0 deletions public_html/layout/denim_curve/functions.php
Expand Up @@ -326,6 +326,7 @@ function theme_init_denim_curve()
$_BLOCK_TEMPLATE['configmanager_block'] = 'blockheader-config.thtml,blockfooter-config.thtml';
$_BLOCK_TEMPLATE['configmanager_subblock'] = 'blockheader-config.thtml,blockfooter-config.thtml';
$_BLOCK_TEMPLATE['whats_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
$_BLOCK_TEMPLATE['articles_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
$_BLOCK_TEMPLATE['story_options_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';

// Define the blocks that are a list of links styled as an unordered list - using class="blocklist"
Expand Down Expand Up @@ -379,6 +380,7 @@ function theme_getThemeItem_denim_curve($item)
case 'core-css-list-feed': // Return 1 or more CSS Classes - For RSS Feed Portal Block - replacing "list-feed"
case 'article-css-list-directory': // Return 1 or more CSS Classes - For Article Directory page - New item as of GL v2.2.1
case 'article-css-list-related': // Return 1 or more CSS Classes - For Article Page What's Related List - replacing 'list-whats-related'
case 'article-css-list-related-articles': // Return 1 or more CSS Classes - For Article Page You might also like
case 'article-css-list-older': // Return 1 or more CSS Classes - For Older Articles Block - replacing "list-older-stories"
case 'topic-css-list-related': // Return 1 or more CSS Classes - For Autotags Related Topic items list - New item as of GL v2.2.1

Expand Down
26 changes: 22 additions & 4 deletions public_html/layout/denim_three/archivearticletext.thtml
Expand Up @@ -37,10 +37,28 @@
{!endif}
{!endif}

{!if related_articles_by_keyword}
<hr{xhtml}>
{related_articles_by_keyword}
{!endif}
<hr{xhtml}>
<div class="uk-margin uk-grid-match" uk-grid>
{!if related_articles_by_keyword}
<div class="uk-width-1-1">
{related_articles_by_keyword}
</div>
{!endif}

<div class="uk-width-1-2@s">
{whats_related}
</div>

<div class="uk-width-1-2@s">
{story_options}
</div>

{!if trackback}
<div class="uk-width-1-1">
{trackback}
</div>
{!endif}
</div>
{!endif}
{!if navi_list}
<ul class="story_navi">
Expand Down
14 changes: 0 additions & 14 deletions public_html/layout/denim_three/article/article.thtml
Expand Up @@ -6,20 +6,6 @@

{# page_number: current page number - page_total: total page count - comments_on_page: if comments will appear on page #}
{!if comments_on_page}
<div class="uk-margin uk-grid-match" uk-grid>
<div class="uk-width-1-2@s">
{whats_related}
</div>

<div class="uk-width-1-2@s">
{story_options}
</div>

<div class="uk-width-1-1">
{trackback}
</div>
</div>

{commentbar}
{!endif}

Expand Down
26 changes: 22 additions & 4 deletions public_html/layout/denim_three/articletext.thtml
Expand Up @@ -37,10 +37,28 @@
{!endif}
{!endif}

{!if related_articles_by_keyword}
<hr{xhtml}>
{related_articles_by_keyword}
{!endif}
<hr{xhtml}>
<div class="uk-margin uk-grid-match" uk-grid>
{!if related_articles_by_keyword}
<div class="uk-width-1-1">
{related_articles_by_keyword}
</div>
{!endif}

<div class="uk-width-1-2@s">
{whats_related}
</div>

<div class="uk-width-1-2@s">
{story_options}
</div>

{!if trackback}
<div class="uk-width-1-1">
{trackback}
</div>
{!endif}
</div>
{!endif}
{!if navi_list}
<ul class="story_navi">
Expand Down
26 changes: 22 additions & 4 deletions public_html/layout/denim_three/featuredarticletext.thtml
Expand Up @@ -37,10 +37,28 @@
{!endif}
{!endif}

{!if related_articles_by_keyword}
<hr{xhtml}>
{related_articles_by_keyword}
{!endif}
<hr{xhtml}>
<div class="uk-margin uk-grid-match" uk-grid>
{!if related_articles_by_keyword}
<div class="uk-width-1-1">
{related_articles_by_keyword}
</div>
{!endif}

<div class="uk-width-1-2@s">
{whats_related}
</div>

<div class="uk-width-1-2@s">
{story_options}
</div>

{!if trackback}
<div class="uk-width-1-1">
{trackback}
</div>
{!endif}
</div>
{!endif}
{!if navi_list}
<ul class="story_navi">
Expand Down
2 changes: 2 additions & 0 deletions public_html/layout/denim_three/functions.php
Expand Up @@ -272,6 +272,7 @@ function theme_init_denim_three()
$_BLOCK_TEMPLATE['configmanager_block'] = 'blockheader-config.thtml,blockfooter-config.thtml';
$_BLOCK_TEMPLATE['configmanager_subblock'] = 'blockheader-config.thtml,blockfooter-config.thtml';
$_BLOCK_TEMPLATE['whats_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
$_BLOCK_TEMPLATE['articles_related_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';
$_BLOCK_TEMPLATE['story_options_block'] = 'blockheader-related.thtml,blockfooter-related.thtml';

// Define the blocks that are a list of links styled as an unordered list - using class="blocklist"
Expand Down Expand Up @@ -325,6 +326,7 @@ function theme_getThemeItem_denim_three($item)
case 'core-css-list-feed': // Return 1 or more CSS Classes - For RSS Feed Portal Block - replacing "list-feed"
case 'article-css-list-directory': // Return 1 or more CSS Classes - For Article Directory page - New item as of GL v2.2.1
case 'article-css-list-related': // Return 1 or more CSS Classes - For Article Page What's Related List - replacing 'list-whats-related'
case 'article-css-list-related-articles': // Return 1 or more CSS Classes - For Article Page You might also like
case 'article-css-list-older': // Return 1 or more CSS Classes - For Older Articles Block - replacing "list-older-stories"
case 'topic-css-list-related': // Return 1 or more CSS Classes - For Autotags Related Topic items list - New item as of GL v2.2.1

Expand Down

0 comments on commit a88b07f

Please sign in to comment.