Couple very minor changes to the display of the stats for Top Referrers page. First, many users will want to see which referrers are the most popular and leave it at that. However, it is more useful to see who has been most recently sent to your site and how often referrers have forwarded people your way.
Next (and most importantly) a 35 character limit is great for display, but if you want to know which search string from google is sending you hits, you need to be able to see the full url. Title makes that trivial.
--- /tmp/statistics.module 2007-04-05 17:20:07.000000000 -0400
+++ statistics/statistics.module 2007-04-05 17:24:10.000000000 -0400
@@ -344,7 +344,7 @@
$header = array(
array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('Url'), 'field' => 'url'),
- array('data' => t('Last visit'), 'field' => 'last'),
+ array('data' => t('Last visit'), 'field' => 'last', 'sort' => 'desc'),
);
$query .= tablesort_sql($header);
@@ -513,7 +513,7 @@
function _statistics_link($path, $width = 35) {
$title = drupal_get_path_alias($path);
$title = truncate_utf8($title, $width, FALSE, TRUE);
- return l($title, $path);
+ return l($title, $path, array('title' => $path));
}
function _statistics_format_item($title, $path) {
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | top_referrers_0.txt | 1.95 KB | mgifford |
| #5 | top_referrers.txt | 977 bytes | mgifford |
Comments
Comment #1
bdragon commentedNew features go against HEAD. Patches need to be attached to be easily reviewed.
Thanks.
Comment #2
mgiffordI believe it was submitted against head a while back.. head changed though.. How's this..
--- statistics.module.old 2007-07-02 13:09:48.000000000 -0400
+++ statistics.module 2007-07-02 13:09:21.000000000 -0400
@@ -338,7 +338,7 @@
$header = array(
array('data' => t('Hits'), 'field' => 'hits', 'sort' => 'desc'),
array('data' => t('Url'), 'field' => 'url'),
- array('data' => t('Last visit'), 'field' => 'last'),
+ array('data' => t('Last visit'), 'field' => 'last', 'sort' => 'desc'),
);
$query .= tablesort_sql($header);
@@ -509,7 +509,7 @@
function _statistics_link($path, $width = 35) {
$title = drupal_get_path_alias($path);
$title = truncate_utf8($title, $width, FALSE, TRUE);
- return l($title, $path);
+ return l($title, $path, array('title' => $path));
}
function _statistics_format_item($title, $path) {
Comment #3
cburschka"Attach" means you save the patch as a text file and upload it using the "File attachment" form below the post. Please don't paste it in the post, as it firstly clutters the page and secondly will get filtered by both Drupal (removing HTML tags and what may look like one) and your browser (removing extra whitespace) so it is highly unlikely to still match if you try to copy and apply it.
Comment #4
gábor hojtsyHow come you think that adding two default ordering arguments would work? The idea behind sorting by number of hits is that this page is a 'top referrers page', so the top ones are on the top basically. The sorting API works by sorting by one column at a time.
The nature of this patch would move the page away from being a top referrers listing, so it is a feature request, not a bug report. Let's at least discuss this some more, whether this makes sense usability-wise, while all other pages are "top something" in the stats module output.
Comment #5
mgiffordArancaytar, I've copied the code into a file that I have now attached. People do this both ways though and for the two line change I was proposing it seemed like it wasn't worth the bother of attaching a file. I can try to attach files more in the future though.
Gábor, the patch has been working for me but the default display doesn't order them by who has sent the most people to your site. I do think that it is much more useful for people to track who is sending people to your site in the last day or so than it is to know that the top referrer has now sent 4030 hits your way (where as maybe the last time you looked at it there were only 4002). When ordered by number of hits it is hard to learn what new is happening to your site. It is useful to see the count on each referrer by default, but for people who are actively watching where there links are coming from this display isn't all that useful.
True about the two sort orders, I guess the one I added trumped the one that was there. I revised my patch.
The naming thing is a bit of an issue though as people would probably expect the top referrers to be ordered by the count. However, how often do you presently check the top referrers? Would you check recent referrers more often? Does it need to be something that the user can configure themselves?
I thought I added this as a feature request, but that was quite some time ago now so not sure.
And yes, would totally like some more feedback from both usability folks and seo folks.
Comment #6
mgiffordOh yeah, for usability, might be useful to modify the menu entry too then so that Recent referrers gets added to the list of other recent logs (Recent log entries, Recent hits & Recent keywords).
The patch is starting to get longer, sorry..
Anyways, this will make the default behavior easier for people who want to keep an eye on recent referral information, but also allow people to easily change the sort order to search by top counts too.
Mike
Comment #7
dave reidLet's split out the two additions here. Adding the title attribute I would easily RTBC, but changing top referrers to recent referrers warrants more discussion.
Comment #8
dave reidPlease go help review #79079: Add title attribute to show the full URL with truncated links created with _statistics_link()
Comment #9
dave reidComment #10
jhodgdonCareful about truncate_utf8() here:
#768040: truncate_utf8() only works for latin languages (and drupal_substr has a bug)
Comment #11
jhodgdontruncate_utf8() is being fixed, so ignore #10.
Comment #12
jhodgdontagging
Comment #13
mgiffordPushing forward to D8
Comment #14
Laurareid commentedi want to implement something similar on my site http://iopenat.com
I am a little worried though that it might result in a lot of spam. has anyone had any issues at all?
Comment #15
jhodgdonLaurareid:
This is a Drupal core feature request... It looks like you need some Drupal support. Please do not take existing issues and ask Drupal support questions on them. Instead, there are several support options listed if you click on "Support" at the top of Drupal.org, which will take you to:
http://drupal.org/support
There you can find out about the Drupal IRC channels, and the Forums, which are our two main support mechanisms in the Drupal community.
Good luck with getting your question answered.
Comment #16
mgiffordI think this code isn't in Core any more.