Skip to content

Commit

Permalink
Added 2 custom block locations for articles
Browse files Browse the repository at this point in the history
Includes one after full article display and one that repeats on the topic page where article intros are listed
  • Loading branch information
eSilverStrike committed Mar 14, 2018
1 parent 9eb2fc2 commit f6f9c2d
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 5 deletions.
12 changes: 12 additions & 0 deletions language/english.php
Expand Up @@ -926,6 +926,17 @@
'block_type_dynamic' => 'Dynamic'
);

###############################################################################
# Block Locations

$LANG23 = array (
'blocks_article_footer_name' => 'Article Footer',
'blocks_article_footer_desc' => 'Display Blocks in article Footer',

'blocks_article_topic_list_name' => 'Article Topic List',
'blocks_article_topic_list_desc' => 'Displays Blocks right after every X number of articles in topics.'
);

###############################################################################
# admin/article.php

Expand Down Expand Up @@ -2266,6 +2277,7 @@
'whats_related_max' => "Max What's Related to Display",
'whats_related_trim' => "What's Related Title Length",
'default_cache_time_article' => "Default Article Cache Time",
'blocks_article_topic_list_repeat_after' => "Article Topic List Blocks Location Repeat",
'aftersave_user' => "After Saving User",
'show_right_blocks' => "Always Show Right Blocks?",
'showfirstasfeatured' => "Show First Article as Featured?",
Expand Down
12 changes: 12 additions & 0 deletions language/english_utf-8.php
Expand Up @@ -926,6 +926,17 @@
'block_type_dynamic' => 'Dynamic'
);

###############################################################################
# Block Locations

$LANG23 = array (
'blocks_article_footer_name' => 'Article Footer',
'blocks_article_footer_desc' => 'Display Blocks in article Footer',

'blocks_article_topic_list_name' => 'Article Topic List',
'blocks_article_topic_list_desc' => 'Displays Blocks right after every X number of articles in topics.'
);

###############################################################################
# admin/article.php

Expand Down Expand Up @@ -2268,6 +2279,7 @@
'whats_related_max' => "Max What's Related to Display",
'whats_related_trim' => "What's Related Title Length",
'default_cache_time_article' => "Default Article Cache Time",
'blocks_article_topic_list_repeat_after' => "Article Topic List Blocks Location Repeat",
'aftersave_user' => "After Saving User",
'show_right_blocks' => "Always Show Right Blocks?",
'showfirstasfeatured' => "Show First Article as Featured?",
Expand Down
12 changes: 12 additions & 0 deletions language/japanese_utf-8.php
Expand Up @@ -931,6 +931,17 @@
'block_type_dynamic' => 'ダイナミック'
);

###############################################################################
# Block Locations

$LANG23 = array (
'blocks_article_footer_name' => 'Article Footer',
'blocks_article_footer_desc' => 'Display Blocks in article Footer',

'blocks_article_topic_list_name' => 'Article Topic List',
'blocks_article_topic_list_desc' => 'Displays Blocks right after every X number of articles in topics.'
);

###############################################################################
# admin/article.php

Expand Down Expand Up @@ -2274,6 +2285,7 @@
'whats_related_max' => '表示する関連情報の最大数',
'whats_related_trim' => '関連情報のタイトルの最大長',
'default_cache_time_article' => '記事のキャッシュ期間のデフォルト',
'blocks_article_topic_list_repeat_after' => "Article Topic List Blocks Location Repeat",
'aftersave_user' => 'ユーザー保存後の画面遷移',
'show_right_blocks' => '右ブロックを常に表示する',
'showfirstasfeatured' => '最初の記事を注目記事として表示する',
Expand Down
1 change: 1 addition & 0 deletions public_html/admin/configuration_validation.php
Expand Up @@ -225,6 +225,7 @@
$_CONF_VALIDATE['Core']['whats_related_max'] = array('rule' => 'numeric');
$_CONF_VALIDATE['Core']['whats_related_trim'] = array('rule' => 'numeric');
$_CONF_VALIDATE['Core']['default_cache_time_article'] = array('rule' => 'numeric');
$_CONF_VALIDATE['Core']['blocks_article_topic_list_repeat_after'] = array('rule' => 'numeric');

/* Subgroup Stories and Trackback, Tab Trackback */
$_CONF_VALIDATE['Core']['trackback_enabled'] = array('rule' => 'boolean');
Expand Down
1 change: 1 addition & 0 deletions public_html/admin/install/config-install.php
Expand Up @@ -145,6 +145,7 @@ function install_config()
$c->add('whats_related_max',0,'text',1,7,NULL,1370,TRUE, $me, 7);
$c->add('whats_related_trim',26,'text',1,7,NULL,1380,TRUE, $me, 7);
$c->add('default_cache_time_article',0,'text',1,7,NULL,1390,TRUE, $me, 7);
$c->add('blocks_article_topic_list_repeat_after',1,'text',1,7,NULL,1400,TRUE, $me, 7);

$c->add('tab_trackback', NULL, 'tab', 1, 8, NULL, 0, TRUE, $me, 8);
$c->add('fs_trackback', NULL, 'fieldset', 1, 8, NULL, 0, TRUE, $me, 8);
Expand Down
4 changes: 4 additions & 0 deletions public_html/docs/english/config.html
Expand Up @@ -472,6 +472,10 @@ <h3><a name="stories_story">Articles and Trackback: Article</a></h3>
<li>0 = Not cached. Article is always regenerated.</li>
<li>-1 = Always cached and only regenerated when the article is updated and saved through the article editor.</li>
</ul></td></tr>
<tr>
<td valign="top"><a name="desc_blocks_article_topic_list_repeat_after">blocks_article_topic_list_repeat_after</a></td>
<td valign="top">1</td>
<td valign="top">Article topic list blocks location repeats after this many article introductions are displayed in a topic.</td></tr>
</table>

<h3><a name="stories_trackback">Articles and Trackback: Trackback</a></h3>
Expand Down
4 changes: 4 additions & 0 deletions public_html/docs/japanese/config.html
Expand Up @@ -433,6 +433,10 @@ <h3><a name="stories_story">記事とトラックバック: 記事</a></h3>
<li>0 = キャッシュしません。記事は常にデータベースから生成されます。</li>
<li>-1 = 常にキャッシュし、エディターで記事を更新・保存した場合に限り、キャッシュを再生成します。</li>
</ul></td></tr>
<tr>
<td valign="top"><a name="desc_blocks_article_topic_list_repeat_after">blocks_article_topic_list_repeat_after</a></td>
<td valign="top">1</td>
<td valign="top">Article topic list blocks location repeats after this many article introductions are displayed in a topic.</td></tr>
</table>

<h3><a name="stories_trackback">記事とトラックバック: トラックバック</a></h3>
Expand Down
6 changes: 4 additions & 2 deletions public_html/index.php
Expand Up @@ -346,7 +346,8 @@ function fixTopic(&$A, $tid_list)
}

// display first article
$display .= STORY_renderArticle($story, 'y');
$articlecount = 1; // Post count of page
$display .= STORY_renderArticle($story, 'y', '', '', $articlecount);

// get plugin center blocks after featured article
if ($story->DisplayElements('featured') == 1) {
Expand All @@ -355,10 +356,11 @@ function fixTopic(&$A, $tid_list)

// get remaining stories
while ($A = DB_fetcharray($result)) {
$articlecount++;
fixTopic($A, $tid_list);
$story = new Article();
$story->loadFromArray($A);
$display .= STORY_renderArticle($story, 'y');
$display .= STORY_renderArticle($story, 'y', '', '' , $articlecount);
}

// get plugin center blocks that follow articles
Expand Down
7 changes: 7 additions & 0 deletions public_html/layout/denim/articletext.thtml
Expand Up @@ -54,6 +54,13 @@
{!endif}
</article>

{!if blocks_article_footer}
{blocks_article_footer}
{!endif}
{!if blocks_article_topic_list}
{blocks_article_topic_list}
{!endif}

<!-- BEGIN image_noalign -->
{!if link_url}
<figure class="gl-article-figure">
Expand Down
7 changes: 7 additions & 0 deletions public_html/layout/denim_three/articletext.thtml
Expand Up @@ -54,6 +54,13 @@
{!endif}
</article>

{!if blocks_article_footer}
{blocks_article_footer}
{!endif}
{!if blocks_article_topic_list}
{blocks_article_topic_list}
{!endif}

<!-- BEGIN image_noalign -->
{!if link_url}
<figure class="gl-article-figure" uk-lightbox>
Expand Down
7 changes: 7 additions & 0 deletions public_html/layout/modern_curve/articletext.thtml
Expand Up @@ -59,6 +59,13 @@
{!endif}
</div>

{!if blocks_article_footer}
{blocks_article_footer}
{!endif}
{!if blocks_article_topic_list}
{blocks_article_topic_list}
{!endif}

<!-- BEGIN image_noalign -->
{!if link_url}
<div class="gl-article-figure">
Expand Down
2 changes: 2 additions & 0 deletions sql/updates/mysql_2.1.3_to_2.2.0.php
Expand Up @@ -109,6 +109,8 @@ function update_ConfValuesFor220()
// Config option for enable/disable logging of 404 errors
$c->add('404_log',1,'select',7,31,1,1840,TRUE, $me, 31);

// Config option to control how often the Article Topic List Block repeats on the page
$c->add('blocks_article_topic_list_repeat_after',1,'text',1,7,NULL,1400,TRUE, $me, 7);

return true;
}
Expand Down
4 changes: 4 additions & 0 deletions sql/updates/pgsql_2.1.3_to_2.2.0.php
Expand Up @@ -108,6 +108,10 @@ function update_ConfValuesFor220()

// Config option for enable/disable logging of 404 errors
$c->add('404_log',1,'select',7,31,1,1840,TRUE, $me, 31);

// Config option to control how often the Article Topic List Block repeats on the page
$c->add('blocks_article_topic_list_repeat_after',1,'text',1,7,NULL,1400,TRUE, $me, 7);


return true;
}
Expand Down
53 changes: 50 additions & 3 deletions system/lib-article.php
Expand Up @@ -57,13 +57,13 @@
* submit.php and admin/article.php (Preview mode for the last two).
*
* @param Article $story The story to display, an instance of the Story class.
* @param string $index n = Full display of article. p = 'Preview' mode. Else introtext only.
* @param string $index n = Full display of article. p = 'Preview' mode. Else y = introtext only.
* @param string $storyTpl The template to use to render the story.
* @param string $query A search query, if one was specified.
* @return string Article as formatted HTML.
* Note: Formerly named COM_Article, and re-written totally since then.
*/
function STORY_renderArticle($story, $index = '', $storyTpl = 'articletext.thtml', $query = '')
function STORY_renderArticle($story, $index = '', $storyTpl = 'articletext.thtml', $query = '', $articlecount = 1)
{
global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB,
$_IMAGE_TYPE, $mode;
Expand Down Expand Up @@ -646,13 +646,30 @@ function STORY_renderArticle($story, $index = '', $storyTpl = 'articletext.thtml
}

PLG_templateSetVars($article_filevar, $article);
// Used by Custom Block Locations (needs to be done before cache)
if ($index == 'n') { // p = preview, n = full article, y = intro only (displayed in topics)
PLG_templateSetVars($article_filevar . '_full', $article);
} elseif ($_CONF['blocks_article_topic_list_repeat_after'] > 0) {
if ($index == 'y' && ($articlecount %$_CONF['blocks_article_topic_list_repeat_after'] == 0)) {
PLG_templateSetVars($article_filevar . '_topic_list', $article);
}
}

if ($index != 'p' && ($cache_time > 0 || $cache_time == -1)) {
$article->create_instance($cacheInstance, $article_filevar);
// CACHE_create_instance($cacheInstance, $article);
}

} else {
PLG_templateSetVars($article_filevar, $article);
// Used by Custom Block Locations
if ($index == 'n') { // p = preview, n = full article, y = intro only (displayed in topics)
PLG_templateSetVars($article_filevar . '_full', $article);
} elseif ($_CONF['blocks_article_topic_list_repeat_after'] > 0) {
if ($index == 'y' && ($articlecount %$_CONF['blocks_article_topic_list_repeat_after'] == 0)) {
PLG_templateSetVars($article_filevar . '_topic_list', $article);
}
}

if (!$_CONF['cache_templates']) {
// Hack (see Geeklog Bug Tracker issue #0001817): Cannot set the template variable directly with set_var since
Expand All @@ -663,7 +680,7 @@ function STORY_renderArticle($story, $index = '', $storyTpl = 'articletext.thtml
$article->templateCode[$article_filevar] = $retval;
}
}

$article->parse('finalstory', $article_filevar);

return $article->finish($article->get_var('finalstory'));
Expand Down Expand Up @@ -1779,6 +1796,36 @@ function plugin_getfeednames_article()
return $feeds;
}

/**
* Return an array of Block Locations in plugin templates
*/
function plugin_getBlockLocations_article()
{
global $LANG23;

$block_locations = array();

// Add any extra block locations for plugin
// Remember these locations can only appear in templates that PLG_templateSetVars is used with
$block_locations[] = array(
'id' => 'article_footer', // Unique string. No other block location (includes Geeklog itself and any other plugins or themes) can share the same id ("left" and "right" are already taken).
'name' => $LANG23['blocks_article_footer_name'],
'description' => $LANG23['blocks_article_footer_desc'],
'template_name' => 'article_full',
'template_variable' => 'blocks_article_footer'
);

$block_locations[] = array(
'id' => 'article_topic_list', // Unique string. No other block location (includes Geeklog itself and any other plugins or themes) can share the same id ("left" and "right" are already taken).
'name' => $LANG23['blocks_article_topic_list_name'],
'description' => $LANG23['blocks_article_topic_list_desc'],
'template_name' => 'article_topic_list',
'template_variable' => 'blocks_article_topic_list'
);

return $block_locations;
}

/**
* Config Option has changed. (use plugin api)
*
Expand Down

0 comments on commit f6f9c2d

Please sign in to comment.