From: Demian K. <dem...@vi...> - 2010-07-19 14:45:41
|
Which version of VuFind are you using? These notes apply to VuFind 1.0 -- if you have an earlier release candidate, things are mostly similar, but the template step is a little different since older versions don't have record drivers. 1.) Before you can index data into a field, you need to define the field in your Solr index. You can do this by editing solr/biblio/conf/schema.xml under your VuFind installation. The exact settings here depend on your needs. name will be the field name you also use in marc_local.properties. type will probably be "string" (if you just want to store a string for display without search considerations) but could be "text" if you want keyword searching access. stored should be "true" so you can read back the data. indexed will probably be "false" unless you want the field to be searchable. multiValued can be excluded unless you need multiple values for the field within a single record. So here's a likely example: <field name="myvar" type="string" indexed="false" stored="true" /> 2.) Now that you have a field available in Solr (be sure to restart VuFind after making this change!), you can add data to it via marc.properties as you described. 3.) Once data is present in the field, it will show up in the fields property of the MarcRecord class that gets instantiated whenever data about the record is displayed. You can find this class in web/RecordDrivers/MarcRecord.php. Note that much of the class' functionality is inherited from IndexRecord (found in IndexRecord.php in the same directory). To display your custom content, you just need to assign the value to the interface in the appropriate method of the record driver and then edit the corresponding template... so, for example, if you want to make it part of the core metadata, you could add this to MarcRecord.php: public function getCoreMetadata() { // New MARC-specific code: global $interface; $interface->assign('coreMyvar', $this->fields['myvar']); // Continue performing standard index-based behavior: return parent::getCoreMetadata(); } ...and then you would need to add something like this to web/interface/default/RecordDrivers/Index/core.tpl: <tr valign="top"> <th>{translate text='My Variable'}: </th> <td> {$coreMyvar|escape} </td> </tr> (I don't claim that this is the smartest or best-organized way to do this -- it's just an example to show you where the files live). Hopefully this is enough to get you started. Please let me know if you have problems or further questions! - Demian > -----Original Message----- > From: MJKL Seige [mailto:mjk...@go...] > Sent: Friday, July 16, 2010 4:08 PM > To: vuf...@li... > Subject: [VuFind-Tech] var from properties to template > > Hello, > > I'd like to define a new field in marc_local.properties in order to > have > it available in the templates later. > > For instance > > myvar = "Hello World" > > and later I'd like to use {$myvar} in, lets say, view.tpl > Where is defined which variables are available in the template files? I > just can't find it. > > Of course I'like to put some dynamic content in myvar later. > > Thanks, > mjkl > > ----------------------------------------------------------------------- > ------- > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > Vufind-tech mailing list > Vuf...@li... > https://lists.sourceforge.net/lists/listinfo/vufind-tech |