1 daniel Sep 29, 2007 23:18
3 afwas Oct 05, 2007 08:53
Hi Daniel,
Glad you reminded me. I looked into this, but forgot to finish things and finaly forgot all about it B) . My question is: what you want, does it resemble a sticky post? If so, have a look at [url=http://forums.b2evolution.net/viewtopic.php?t=10233&start=0&postdays=0&postorder=asc&highlight=sticky][Plugin] Sticky Post[/url] by balupton.
Good luck
4 daniel Oct 05, 2007 10:30
Ah, no, not necessarily. Similar to my TOP 15 article-headlines displayed in the sidebar, I was looking for a possibility to not only show my most viewd postings of all time, but e.g. of the actual month (as well). So I (and all visitors) could see, what is/was of interest the most in the current month... and I would like to implement this in the sidebar... so for my understanding, no interaction with the sticky post plugin...
5 afwas Oct 05, 2007 10:40
Can you provide me the code of the top 15 list?
6 daniel Oct 05, 2007 10:44
Sure... especially because I couldn´t find it in the forum anymore... but I got the help from here... somewhere...
<!-- =============== TOP ARTICLES =============== -->
<?php
echo "<div class=\"bSideItem\">
<h3 class=\"sideItemTitle\">Top 15 Artikel</h3>";
$TOPART = new ItemList($blog, array(), '', '', -1, '', array(),
'', 'DESC', 'views', 15);
echo "<ul>";
while ($TOPART_ITEM = $TOPART->get_item()) {
echo "<li><a href=\"", $TOPART_ITEM->permanent_url();
echo "\">", $TOPART_ITEM->title('','',false), "</a> <span class=\"notes\">(";
echo $TOPART_ITEM->views;
echo ")</span></li>";
}
echo "<li><a href=\"http://www.chaoszone.de/blog/index.php?orderby=views\">Mehr...</a></li></ul>";
echo"</div>";
?>
7 yabba Oct 05, 2007 11:05
<!-- =============== TOP ARTICLES OF THE MONTH =============== -->
<?php
echo "<div class=\"bSideItem\">
<h3 class=\"sideItemTitle\">Top 15 Artikel</h3>";
$TOPART = new ItemList($blog, array(), '', '', -1, '', array(),
'', 'DESC', 'views', 15, '', '', '', '', '', '', 0, '', mysql2timestamp( date( 'Y-m-01 00:00:00', $servertimenow ) ) );
echo "<ul>";
while ($TOPART_ITEM = $TOPART->get_item()) {
echo "<li><a href=\"", $TOPART_ITEM->permanent_url();
echo "\">", $TOPART_ITEM->title('','',false), "</a> <span class=\"notes\">(";
echo $TOPART_ITEM->views;
echo ")</span></li>";
}
echo "<li><a href=\"http://www.chaoszone.de/blog/index.php?orderby=views\">Mehr...</a></li></ul>";
echo"</div>";
?>
¥
*edit* corrected date ;)
8 afwas Oct 05, 2007 11:23
You want two new instances of this code, but with some minor differences. Most important: change the variable names to avoid conflicts.
Second you want to change this line:
$TOPART = new ItemList($blog, array(), '', '', -1, '', array(),
'', 'DESC', 'views', 15);
[url=http://doc.b2evolution.net/v-1-10/evocore/ItemList.html]Here[/url] is te technical doc's entry for this code.
The single most viewed article ever: change 15 om 1. That's easy.
The most viewed post of the current month:
1) add this code somewhere in the top of your snippet:
$today = getdate();
$this_month = $today[mon];
*edit*
This is the correct solution:
$today = getdate();
$this_month = $today['mon'];
$this_year = $today['year'];
$this_month = $this_year.$this_month;
2) change this line:
$TOPART = new ItemList($blog, array(), '',
$this_month, -1, '', array(), '', 'DESC', 'views', 1);
¥åßßå beats me.
Good luck
9 daniel Oct 05, 2007 13:14
Hey great... I wasn´t aware, that this is a content ;)
¥åßßå, I´ve integrated your code first, and in general it seems to work... There are x headlines displayed, only from this month etc. but before I get 3 times the same error message above the top list entries:
Notice: A non well formed numeric value encountered in /home/www/.../blog/inc/_misc/_misc.funcs.php on line 431
The _misc.funcs.php around the mentioned position says:
/**
* Convert a MYSQL date to a UNIX timestamp
*/
function mysql2timestamp( $m )
{
return mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
}
/**
* Convert a MYSQL date -- WITHOUT the time -- to a UNIX timestamp
*/
function mysql2datestamp( $m )
{
return mktime( 0, 0, 0, substr($m,5,2), substr($m,8,2), substr($m,0,4) );
}
/**
* Format a MYSQL date to current locale date format.
*
* @param string MYSQL date YYYY-MM-DD HH:MM:SS
*/
function mysql2localedate( $mysqlstring )
{
return mysql2date( locale_datefmt(), $mysqlstring );
}
function mysql2localetime( $mysqlstring )
{
return mysql2date( locale_timefmt(), $mysqlstring );
}
function mysql2localedatetime( $mysqlstring )
{
return mysql2date( locale_datefmt().' '.locale_timefmt(), $mysqlstring );
}
function mysql2localedatetime_spans( $mysqlstring )
{
return '<span class="date">'
.mysql2date( locale_datefmt(), $mysqlstring )
.'</span> <span class="time">'
.mysql2date( locale_timefmt(), $mysqlstring )
.'</span>';
}
Afwas, after that I tried your version, and this was the result:
Notice: Use of undefined constant mon - assumed 'mon' in /home/www/.../blog/skins/custom/_main.php on line 7
Warning: Cannot modify header information - headers already sent by (output started at /home/www/.../blog/skins/custom/_main.php:7) in /home/www/.../blog/inc/MODEL/skins/_skin.funcs.php on line 71
Any ideas to make this happen without any error-messages?
10 daniel Oct 05, 2007 13:19
Ah... found the solution, even when I´m not fully understanding this...
$TOPART = new ItemList($blog, array(), '', '', -1, '', array(), '', 'DESC', 'views', 5, '', '', '', '', '', '', 0, '', mysql2timestamp( date( 'Y-m-01 00:00:01', $servertimenow ) ) );
So the working date format shall apparently be "Y-m-01 00:00:0[u]1[/u]"
11 afwas Oct 05, 2007 14:55
Hi Daniel,
Sorry for the inconvenience, I didn't test the code (needed to run). From my solution this works (tested):
$today = getdate();
$this_month = $today['mon'];
$this_year = $today['year'];
$this_month = $this_year.$this_month;
replaces the snippet I mentioned.
This gives a number like 200710 and that triggers the correct month (october 2007).
¥åßßås code also works: he selects ALL posts and limits output to one month. He made a very funny mistake (bet he didn't check either) and you were a true Sherlock Holmes finding the solution.
Happy blogging
12 yabba Oct 05, 2007 17:47
Afwas wrote:
he selects ALL posts and limits output to one month.
Close, it adds a where clause to the mysql to limit the selection of results to just a month ;)
Afwas wrote:
(bet he didn't check either)
Yer meant to test code? 8|
¥
13 daniel Oct 05, 2007 21:19
LOL
(and thanks again for your help)
14 wayfinder Oct 06, 2007 22:13
Thanks from me too, I didn't even know it was possible to sort by popularity (or show single article view counters). Now I'm a little depressed that my second most popular article has over 35000 views less than #1 :D
15 daniel Oct 07, 2007 15:38
OFFTOPIC: 35000 views less? how much hits has your best article and what is your URL?
16 afwas Oct 07, 2007 15:53
wayfinder wrote:
Thanks from me too, I didn't even know it was possible to sort by popularity (or show single article view counters).
If you saw the [url=http://doc.b2evolution.net/v-1-10/evocore/ItemList.html]link[/url], you will notice that you can also sort by: author, issue_date, mod_date, status, locale, content, title, urltitle, url, category, wordcount, and comments.
Good luck
17 wayfinder Oct 07, 2007 18:40
^^^thanks!
Daniel wrote:
OFFTOPIC: 35000 views less? how much hits has your best article and what is your URL?
One of my posts got picked up by stumbleupon and garnered almost 40000 hits :)
Hmm, no solution for that?