Unfortunately, this is a little complicated -- but there's a method to the madness, since this complication is what makes it possible for VuFind to support multiple record types in its index.
All of VuFind's displays are handled by "record driver" classes that take content from the Solr index and render it appropriately. There is a generic "index" record driver which displays content taken from the basic index fields, and there is a "MARC" record driver which enhances the index functionality using data taken directly from the binary MARC record. You can theoretically write your own drivers for other types of records as needed. A technical introduction to record drivers can be found in the wiki here:
http://vufind.org/wiki/other_than_marc#record_display
For your specific question, you want to look at the getSearchResult() method of the record drivers. First, take a look at this method in the IndexRecord class in web/RecordDrivers/IndexRecord.php. Next, take a look at the method in the MarcRecord class in web/RecordDrivers/MarcRecord.php (it may or may not exist there, depending on which version of VuFind you are using). If you don't have a getSearchResult method in MarcRecord, you can create one like this:
public function getSearchResult()
{
$template = parent::getSearchResult();
// Do things...
return $template;
}
The way this method works is that it assigns some fields to Smarty and then returns the name of a template that can be used to display those fields. For your purposes, you have several options -- you can use MarcRecord::getSearchResult to override some of the assignments made by IndexRecord::getSearchResult to include more complete values... OR you can add some new fields in IndexRecord::getSearchResult, populating them with blank values in IndexRecord but real MARC-derived values in MarcRecord OR you can have MarcRecord::getSearchResult return a whole different template name and then build your own layout.
If you do add new values, there is one important detail you need to keep in mind: make sure that every value that you could possible assign to Smarty gets populated with some kind of value. Since your templates will get rendered inside loops, values can bleed over from one record to the next, so it's important to be careful.
For example, code like this could cause a problem:
if ($urlIsFound) {
$interface->assign('url', $url);
}
The first time a URL is found, it will be assigned... and then EVERY record will display that URL if it doesn't have a URL of its own. Instead, you want to do something like this:
$interface->assign('url', $urlIsFound ? $url : '');
Anyway, as I say, it's a bit complicated... but hopefully this will get you started. Some of the existing logic in the record driver classes should be able to serve as a model for what you need to do. Let me know if you still have questions!
- Demian
> -----Original Message-----
> From: Eric Frierson [mailto:ericfr@...]
> Sent: Tuesday, October 26, 2010 9:46 AM
> To: vufind-general
> Subject: [VuFind-General] Editing Record Display to Show/Hide Subfields
>
>
> Hey -
>
> So I'm still working my way past newbie level with vuFind, and I
> apologize if this is already documented somewhere, but I would like to
> add a subfield or two to the results list display. I took a look at
> list-list.tpl, but I only saw reference to a variable $record that
> looked like it contained the data for each item in a results list.
>
> Can someone point me to a file to specify what subfields to display in
> the results list? For example, without displaying a record's 245
> subfield n (volume), there's no way to differentiate volumes of this
> series from one another in the results view:
>
>
> http://184.106.206.136/vufind/Search/Results?lookfor=international+dire
> ctory+of+company+histories&type=AllFields&submit=Find
>
> I also need to display subfield p of 245 in some cases too.
>
> A file name and directory would be great, and I can adjust the code
> accordingly.
>
> -
> Eric Frierson
> Library Digital Services Manager
> Scarborough-Phillips Library, St. Edward's University
> ericfr@... - http://flavors.me/efrierson - 512.428.1290
>
> -----------------------------------------------------------------------
> -------
> Nokia and AT&T present the 2010 Calling All Innovators-North America
> contest
> Create new apps & games for the Nokia N8 for consumers in U.S. and
> Canada
> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
> marketing
> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi
> Store
> http://p.sf.net/sfu/nokia-dev2dev
> _______________________________________________
> VuFind-General mailing list
> VuFind-General@...
> https://lists.sourceforge.net/lists/listinfo/vufind-general
|