Hi, I have a Drupal 6.2 Site under costruction.
I have enabled the popular-content Block.

I ask if there can be a way to filter out the "Page not Found" visualisation from
the Popular-content Block.

The error setting page use equivalent selfmaded "Page not found" nodes.

Error 403 as ?q=node/1
Error 404 as ?q=node/2

site: http://www.adaccs.at/drupal2/

Cheers

Comments

Wolfflow’s picture

Of course it is not a solution but meanwhile you can do an sql query with "phpMyAdmin"
on your Drupal database:

  1. For the "Popular content" - ALL Time
    SQL query:
    SELECT * FROM 'node_counter' WHERE 'totalcount' = (the number of page READS on your "Page not found" node)
    
  2. For the "Popular content" - Last viewed
    SQL query:
    SELECT * FROM 'node_counter' WHERE 'daycount' = (the number of page views on your node)
    

    Same procedure as for 1.

  3. Of course it will show your "Page not Found" NID Number if you put the number of "reads" this
    node have, then you can set it to 0 so that for a while it will not showup again in the "Popular Content" Block.

Cheers

Wolfflow’s picture

Hi all,

I know that this seems not to care anyone, because most of you Drupalist sure have a PHP solution for that !!
But please let you share your solutions with us (no PHP programmers)
Thanks for your hints, and suggestions of documentation what can help me and others to implement a solution.

Cheers

Wolfflow’s picture

Just as a consideration:

It's possible to put an SQL Funtion call in the Statistic Module that on activation of the "Popular-content-Block" will check and reset the node_counter for the NID of the a cuastom "Page_not-found(Node)" and the NID for the custom "Forbidden(Page)" = 0 ?

Or can be the possibility to delete or disable the counting for those node_counter items?

Any help is very much appreciate

AstralP’s picture

Why don't you just use views to build a block to what you require?

Views is perfect for that sort of task :)

EDIT:

Also your best bet is to look at what page not found errors you are getting and build some redirects for the highest ones in the .htaccess file (in the root of your site), that way you can redirect the links to what the user expects and keep people coming from that source.

Wolfflow’s picture

Hi AstralP

If i was that expert with view maybe I have done it, i'm not, and I consider that such a Kind of Bug that is in the
statistical.modul should really be taken in consideration despite the fact that if i give Drupal user the option to
get a custom "Page-not_found" page and a "Forbidden" page in the Drupal administrative settings I should consider that
in the statistic.module wich is Core this event is taken in consideration!

Cheers

gpk’s picture

The following code if put in a block will give you the All time popular content *excluding* any 403 or 404 pages that have been defined. This is largely cribbed from http://api.drupal.org/api/function/statistics_block/6 and http://api.drupal.org/api/function/statistics_title_list/6.

I agree that something like this should be built-in, probably in core.


// First define customised version of statistics_title_list()
function statistics_title_list_custom($dbfield, $dbrows) {
  // This version excludes nodes used for 403 and 404 pages
  $path = $nid = array(); // Arrays to hold path and nid of error pages
  foreach (array(403, 404) as $err_code) {
    $path[$err_code] = drupal_get_normal_path(variable_get("site_$err_code", ''));
    if (substr($path[$err_code], 0, 5) == 'node/') {
      $nid[$err_code] = substr($path[$err_code], 5);
    }
    // If the nid is not valid (i.e. (possibly empty) string, NULL) then set to 0
    $nid[$err_code] = is_numeric($nid[$err_code]) ? $nid[$err_code] : 0;
}
  if (in_array($dbfield, array('totalcount', 'daycount', 'timestamp'))) {
    return db_query_range(db_rewrite_sql("SELECT n.nid, n.title, u.uid, u.name FROM {node} n INNER JOIN {node_counter} s ON n.nid = s.nid INNER JOIN {users} u ON n.uid = u.uid WHERE s.$dbfield != 0 AND n.status = 1 AND n.nid != %d AND n.nid != %d ORDER BY s.$dbfield DESC"), $nid[403], $nid[404], 0, $dbrows);
  }
  return FALSE;
}

// Now get the all time popular content
$alltimetop = variable_get('statistics_block_top_all_num', 0);
if ($alltimetop && ($result = statistics_title_list_custom('totalcount', $alltimetop)) && ($node_title_list = node_title_list($result, t('All time:')))) {
  $content = $node_title_list;
}

print $content;
Wolfflow’s picture

Hi GPK, first that you very much for your cool support.
Very much appraciate and I'm going to implement it right now.
And yes , I know there are some discussions from the core team that this myght be solved or at
list taken in considerationfor the next Drupal release. I hope it will be in the 6.x upgrade version
but surely in version 7. Thank a lot. I let you know.
Cheers

P.S. everything fine on my HP (thanks again)

Wolfflow’s picture

Hi, am here again shortly for a question: Can this be applyed on Drupal version 5.7 too?
I defenitly suppose no, am I right?
Cheers

pcs305’s picture

I'm also interested in a 5.7 version.

(I did try it in 5.7 but it did not work)

gpk’s picture

This was written on 5.x, should also work on 6.x. :)

blucky’s picture

There was a bug at Drupal 5.7 and panel2. It was broke my panel down, maybe you want to take a look for a while. It's working nicely on regular block. Btw how to hidden restricted content type at popular content?

dave reid’s picture

You can use the Statistics Advanced settings to not allow 403 and 404's to be included in node_counter. Considering that the module is in a semi-abandoned (looking for adoption), should this maybe get marked won't fix since there is a solution provided in another (very similar) module?

gpk’s picture

I suspect Views can also do most if not everything that Statistics Filtering can (and probably much more flexibly), at least in 6.x.

Wolfflow’s picture

I am still following this issue.
I did not try the code posted in #6 by gpk,
maybe some one did or anyone have a better idea?

frank ralf’s picture

Status: Active » Postponed (maintainer needs more info)

I'm not sure whether this use case should be handled by this module.

Wolfflow’s picture

Issue summary: View changes
Priority: Critical » Normal
Status: Postponed (maintainer needs more info) » Closed (won't fix)

As the site mentioned in the issue does not exist anymore and because as of Drupal Version 6 and 7 we have many valuable features to deal with statistic module settings I close this issue. Please feel free to reopen if you mind. Thanks to all poster.