CustomizingGridView

From CONTENTdm Users Wiki

Jump to: navigation, search

[edit] Background

The Grid View is one of several views of the Browse and Results pages. By default the fields that show are (title, subject and description in addition to the thumbnail), but often a collection will have a unique metadata field that you want to display. This can be achieved by editing the browse.php and results.php files in the /cdm4/ directory. In each, near the top (10 lines down or so) of the file, you need to add two lines of code to instruct the system to allow unique "cases." You can have a case statement for each collection if you wish.

[edit] Browse/Results.php

--Add these two lines of code:--


switch(substr(urldecode(@$_GET["CISOROOT"]),1)){

default:

--Above this line:--


/* Below are the default viewer parameters */

--Then after this line (which is the end of the default parameters):--


/* Above are the default viewer parameters */

--Add this code (which is a case statement for a particular collection):--


break;

case "alias":

/* Below are the viewer parameters for Unique collection */

define("DEF_CISORESTMP", "results.php");
define("DEF_CISOVIEWTMP", "item_viewer.php");
define("DEF_CISOMODE", "grid"); //grid; title; thumb; bib; hiera
define("DEF_CISOGRID", "thumbnail,A,1;title,A,1;subjec,A,0;descri,200,0;none,A,0;20;title,none,none,none,none");
define("DEF_CISOBIB", "title,A,1,N;subjec,A,0,N;descri,200,0,N;none,A,0,N;none,A,0,N;20;title,none,none,none,none");
define("DEF_CISOTHUMB", "20 (4x5);date,title,none,none,none");
define("DEF_CISOTITLE", "20;title,none,none,none,none");
define("DEF_CISOHIERA", "20;subjec,title,none,none,none");

/* Above are the viewer parameters for Unique collection */
break;

}


[edit] Field Nicknames

You can add more cases above the last closing bracket. But what you'll need to do is edit "define("DEF_CISOGRID", so that instead of title, subjec and descri, you insert the "nicknames" of the fields you want to display.

What are nicknames? Field nicknames are the names the system uses in reference to a collection's metadata fields. It is important to understand that this is not the Dublin Core mapping or the label you have assigned a field. To see what a collection's field nicknames are, go to the collection data folders, and for your collection go to index > etc > config.txt. You will see something like this:


Title:title:TEXT:BIG:BLANK:BLANK:SEARCH:NOHIDE:NOVOCAB:title
Creator:creato:TEXT:BIG:BLANK:BLANK:SEARCH:NOHIDE:VOCAB:creato
Date Original:date:TEXT:SMALL:BLANK:BLANK:SEARCH:NOHIDE:NOVOCAB:date
Description:descri:TEXT:BIG:BLANK:BLANK:SEARCH:NOHIDE:NOVOCAB:descri
Notes:notes:TEXT:SMALL:BLANK:BLANK:NOSEARCH:NOHIDE:NOVOCAB:BLANK
Subject:subjec:TEXT:BIG:BLANK:BLANK:SEARCH:NOHIDE:VOCAB:subjec
Place:place:TEXT:SMALL:BLANK:BLANK:NOSEARCH:NOHIDE:VOCAB:subjec
Coverage:geogra:TEXT:SMALL:BLANK:BLANK:SEARCH:NOHIDE:NOVOCAB:covera

The field nickname is the name right after the field name, not the one at the end (this is the DC mapping). You can see from this example that the field nickname for Subject is "subjec," which is not surprising, but the nickname for Coverage is "geogra" NOT "covera." Enter the field nickname you want to display in Grid View in the "case" for your collection (remember to use the actual collection alias where it says "alias." And make sure you are editing "DEF_CISOGRID." You can edit any of the views, but make sure you are not editing the Default case, since your unique field probalby only exists for that collection.



Please edit these directions if they are not clear. Especially to make the added code section better formatted. I'm not a Wiki Whiz, so my plain text is not the best.


Mark Anderson University of Iowa Libraries.

Personal tools