diff --git a/fp-includes/core/core.fpdb.class.php b/fp-includes/core/core.fpdb.class.php index 7530d27..102cc40 100644 --- a/fp-includes/core/core.fpdb.class.php +++ b/fp-includes/core/core.fpdb.class.php @@ -159,13 +159,12 @@ class FPDB_Query { var $secondary_idx = null; var $walker = null; - + var $prevkey = null; - + var $nextkey = null; - + var $comments = null; - function __construct($params, $ID) { global $current_query; @@ -849,6 +848,13 @@ function smarty_block_entry($params, $content, &$smarty, &$repeat) { $smarty->assignByRef('id', $id); + // If PostViews plugin is active: Trigger view counter! + // This seems a bit hackish; please fix if possible. + // See also commented line "// add_action('entry_block', 'plugin_postviews_do');" in plugin.postviews.php + if (function_exists('plugin_postviews_do')) { + plugin_postviews_do($smarty, $id); + } + if (array_key_exists('categories', $entry)) { $smarty->assign('entry_commslock', in_array('commslock', $entry ['categories'])); } diff --git a/fp-plugins/postviews/plugin.postviews.php b/fp-plugins/postviews/plugin.postviews.php index b5a2bbe..c7f02d8 100644 --- a/fp-plugins/postviews/plugin.postviews.php +++ b/fp-plugins/postviews/plugin.postviews.php @@ -7,7 +7,11 @@ * Author URI: https://www.flatpress.org * Description: Counts and displays entry views. Part of the standard distribution. */ -add_action('entry_block', 'plugin_postviews_do'); + +// This seems a bit hackish; please fix if possible. +// The action hook seems to come "to late", the 'views' variable assignment in plugin_postviews_do() does not have effect on the (already parsed?) template. +// For now, smarty_block_entry() in core.fpdb.class.php takes care of calling plugin_postviews_do() early enough. +// add_action('entry_block', 'plugin_postviews_do'); function plugin_postviews_calc($id, $calc) { $dir = entry_dir($id); @@ -32,18 +36,17 @@ function plugin_postviews_calc($id, $calc) { $v++; io_write_file($f, $v); } - + return $v; } -function plugin_postviews_do($id) { - global $fpdb, $smarty; - +function plugin_postviews_do($smarty, $id) { + global $fpdb; + $q = $fpdb->getQuery(); $calc = $q->single; $v = plugin_postviews_calc($id, $calc); - $smarty->assign('views', $v); }