About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
development:howtos:displaying_a_custom_field:vufind6_example

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
development:howtos:displaying_a_custom_field:vufind6_example [2020/04/14 13:01] demiankatzdevelopment:howtos:displaying_a_custom_field:vufind6_example [2023/11/09 21:31] demiankatz
Line 1: Line 1:
-====== Displaying a Custom Theme: VuFind 6.x Example ======+====== Displaying a Custom Field: VuFind 6.x (or newer) Example ======
  
 // This example shows you how to set up a custom module, custom theme and custom record driver. It assumes that you have already added a custom field to your Solr index named RecID -- you can see more concrete examples of adding fields on the [[indexing:adding_facets|Adding Facets]] page. // // This example shows you how to set up a custom module, custom theme and custom record driver. It assumes that you have already added a custom field to your Solr index named RecID -- you can see more concrete examples of adding fields on the [[indexing:adding_facets|Adding Facets]] page. //
Line 110: Line 110:
 :!: In this example, the key line is $spec->setLine('Record ID', 'getRecordID'); in your custom RecordDataFormatterFactory. This tells VuFind to call the record driver's getRecordID() method and display the value(s) with a label of "Record ID." This is an easy way to add a simple label-value pair to your display. If you instead needed to display the value in a more complex way requiring a custom template, you could instead say $spec->setTemplateLine('Record ID', 'getRecordID', 'data-recordid.phtml') and then create a $VUFIND_HOME/themes/ThemeName/templates/RecordDriver/SolrMarc/data-recordid.phtml template containing appropriate formatting logic. The value(s) from getRecordID will be available in the template as a PHP variable named $data. :!: In this example, the key line is $spec->setLine('Record ID', 'getRecordID'); in your custom RecordDataFormatterFactory. This tells VuFind to call the record driver's getRecordID() method and display the value(s) with a label of "Record ID." This is an easy way to add a simple label-value pair to your display. If you instead needed to display the value in a more complex way requiring a custom template, you could instead say $spec->setTemplateLine('Record ID', 'getRecordID', 'data-recordid.phtml') and then create a $VUFIND_HOME/themes/ThemeName/templates/RecordDriver/SolrMarc/data-recordid.phtml template containing appropriate formatting logic. The value(s) from getRecordID will be available in the template as a PHP variable named $data.
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
development/howtos/displaying_a_custom_field/vufind6_example.txt · Last modified: 2023/11/09 21:32 by demiankatz