Recent Topics

1 Jan 10, 2015 20:08    

Hi I have been trying to find a variable that will give me the total number of posts per blog. After many hours I did find something that gave me the total for the database but that included all post from all blogs.

So despite my reticence I decided to have a go at an SQL query and came up with this, although I'm sure there is some way of using SQL COUNT.

Something odd: On one of my domains the count is out by 1

Is there a simple inbuilt variable?

// getting postcount
		mysql_connect("localhost", "userName", "passWord") or die(mysql_error());
		mysql_select_db("dataBaseName") or die(mysql_error());
		$row_query = "
			SELECT evo_items__item.post_main_cat_ID,
					evo_items__item.post_ptyp_ID,
					evo_items__item.post_status,
					evo_categories.cat_ID,
					evo_categories.cat_blog_ID
			FROM evo_items__item
			JOIN evo_categories
			ON evo_items__item.post_main_cat_ID = evo_categories.cat_ID
			AND evo_categories.cat_blog_ID = $Blog->ID
			AND evo_items__item.post_ptyp_ID = 1
			AND evo_items__item.post_status = 'published'
					";		
		$row_result = mysql_query($row_query) or die(mysql_error());
		$postcount = 1;
		 while($evo_items_item_row = mysql_fetch_array($row_result) )
	 		{		
				$postcount++;
			}

		$listplots = $postcount;

echo '<a href="http://' . $_SERVER['HTTP_HOST'] . '/' . $Blog->name . '.php?disp=postidx">Paged Index of All <b>' . $listplots . '</b> Posts</a>';

And I have css styling (not included above) for the echo

You can see it working at http://calstock.org.uk/elf.php

The count per page number was set in [/skin/_postidx.disp.php]
LIne 28: 'limit' => 10,
and copied to [/skin/my_usual.skin/_postidx.disp.php]

See also http://rogerlovejoy.net/blog/b2evo.php

2 11 Jan 2015 01:34

Adding variables at beginning to incorporate 'members/protected' posts for registered users when logged in.

<code>
$reg = 'published';
if (isset($current_User))
$reg = 'protected';
</code>

and updated last line of query to use variable

<code>
AND (evo_items__item.post_status = 'published' OR evo_items__item.post_status = '$reg')
</code>


Form is loading...