Custom type order when display by type

larmarange
2009-04-29
2013-05-28
  • larmarange
    larmarange
    2009-04-29

    When citations are displayed by type or type-year, types are ordered alphabetically (BY type DESC). But in an academic use, Books are often presented first, then journal articles and report at the end.

    It would be fine to have the possibility to specify in initialize/ini.inc.php the order of types to display.

    Below, a suggestion:

    In initialize/ini.inc.php, add :

        // When results are displayed by type, type order to use:
        // The specified reference types must have matching entries within the 'types' MySQL table.
        $typeOrder = "'Book Whole','Book Chapter','Journal Article','Journal','Thesis','Conference Volume','Conference Article','Report','Abstract','Patent','Software','Magazine Article','Newspaper Article','Manual','Manuscrit','Map','Miscellaneaous'";
        // e.g. "'Book Whole','Book Chapter','Journal Article','Journal','Thesis','Conference Volume','Conference Article','Report','Abstract','Patent','Software','Magazine Article','Newspaper Article','Manual','Manuscrit','Map','Miscellaneaous'"
       
        // When results are displayed by type, thesis order to use:
        // The specified reference types must have matching entries within the 'thesis' field in 'ref' MySQL table.
        $thesisOrder = "'Habilitation thesis','Ph.D. thesis','Doctoral thesis','Master\'s thesis','Diploma thesis','Bachelor\'s thesis'";
        // e.g. "'Habilitation thesis','Ph.D. thesis','Doctoral thesis','Master's thesis','Diploma thesis','Bachelor's thesis'"

    In search.php, show.php and includes/include.inc.php, replace :

    ORDER BY type DESC, thesis DESC

    by

    ORDER BY FIELD(type, $typeOrder), FIELD(thesis, $thesisOrder)

    (8 replacements)

    In includes/include.ini.inc, line 2453, add:

    global $typeOrder, $thesisOrder; // defined in 'ini.inc.php'

    In search.php, line 4911 and line 5018, add :

    global $typeOrder, $thesisOrder; // defined in 'ini.inc.php'

    An example of a custom type order can be viewed here :

    http://www.ceped.org/biblio/show.php?author=des&citeOrder=type&showQuery=1

    or

    http://www.ceped.org/biblio/show.php?author=la&citeOrder=type&showQuery=1

    Regards

     
    • larmarange
      larmarange
      2009-04-30

      Note: be careful.  This code is just proposed to discussion, not to be used in production. It can produce some errors.

      A problem identified (but I don't know how to fix the problem):

      With the modified show.php:

      With a web navigator:
      - show.php?records=all&citeOrder=year OK no problem
      - show.php?records=all&citeOrder=type OK no problem

      With use of file_get_contents in a php script:

      - file_get_contents('http://url_of_refbase/show.php?records=all&citeOrder=year') OK no problem
      - file_get_contents('http://url_of_refbase/show.php?records=all&citeOrder=type') doesn't work: Error 1065 : Query was empty

       
    • Hi Joseph,

      thanks for all your recent forum contributions, keep it coming! I'm a bit busy with other things right now, but I'll try to respond as soon as I can.

      Your proposal looks interesting, and it would be nice to support something along these lines. However, I haven't actually been able to test it yet.

      W.r.t. 'file_get_contents()', have you tried to use 'fopen()' instead? refbase uses 'fopen()' in 'index.php' via function 'fetchDataFromURL()' (in file 'includes/include.inc.php'), and this doesn't seem to pose any problems with 'citeOrder=type'.

      Matthias