Custom field display problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Custom field display problem

Schulkins, Joe

Hi,

 

I'm trying to display a custom field in Vufind, I've followed the instructions at https://vufind.org/wiki/development:howtos:displaying_a_custom_field but it’s not coming through.

 

I can see the field in the Staff View tab so it is being populated on import.

 

My getter is:

 

   public function getScaRef()

     {

        return isset($this->fields['sca_ref'])

             ? $this->fields['sca_ref'] : [];

     }

 

Path to module SolrMarc is: $VUFIND_HOME/module/Emu/src/Emu/RecordDriver/SolrMarc.php

 

Calling it in my theme:

 

<? $reference = $this->driver->getScaRef(); if (!empty($reference)): ?>

<tr>

<th><?=$this->transEsc('Reference Number')?>: </th>

<td property="scaReference"><?=$this->escapeHtml($reference)?></td>

</tr>

<? endif; ?>

 

Path to theme template is: $VUFIND_HOME/themes/livuni/templates/RecordDriver/Emu/core.phtml

 

I have missed something obvious or are there any logs etc. which can point me in the right direction?

 

In addition, I would like to add this field to the Hierarchy Tree alongside the title. Is there a way to do this?

 

Thanks,

Joe

 

Joseph Schulkins | Systems Librarian | Libraries, Museums and Galleries | PO Box 123 | Liverpool L69 3DA | [hidden email] T 0151 794 3844

 

Follow us@LivUniLibrary   Like usLivUniLibrary   Visit ushttp://www.liv.ac.uk/library

Special Collections & Archives bloghttp://manuscriptsandmore.liv.ac.uk

Victoria Galleries and Museumhttp://vgm.liverpool.ac.uk

Garstang Museumhttp://www.liverpool.ac.uk/garstang-museum

 

ignature_808012961


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
VuFind-General mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Custom field display problem

Demian Katz

Joe,

 

I see that you are extending the SolrMarc record driver, but you mention seeing the field in the Staff View tab. If the Staff View tab is showing Solr data rather than MARC data, that probably means your data is being presented by the SolrDefault driver rather than the SolrMarc driver. VuFind loads a different record driver based on the contents of the recordtype field in the index; if no driver matching the pattern “Solr” + recordtype value is found, it defaults to “SolrDefault.” Is it possible your problem is that you are not extending the driver that is actually being used?

 

Regarding your custom hierarchy title display, one simple approach may be to make use of the title_in_hierarchy field while indexing – just concatenate the values into this field at index time. (See https://vufind.org/wiki/indexing:hierarchies_and_collections for more details on the field). That may be a somewhat crude solution, but it should work without any code changes. If you need something more sophisticated, you may have to override a couple of classes – let me know if you want more details.

 

- Demian

 

From: Schulkins, Joe [mailto:[hidden email]]
Sent: Wednesday, July 05, 2017 8:15 AM
To: '[hidden email]'
Subject: [VuFind-General] Custom field display problem

 

Hi,

 

I'm trying to display a custom field in Vufind, I've followed the instructions at https://vufind.org/wiki/development:howtos:displaying_a_custom_field but it’s not coming through.

 

I can see the field in the Staff View tab so it is being populated on import.

 

My getter is:

 

   public function getScaRef()

     {

        return isset($this->fields['sca_ref'])

             ? $this->fields['sca_ref'] : [];

     }

 

Path to module SolrMarc is: $VUFIND_HOME/module/Emu/src/Emu/RecordDriver/SolrMarc.php

 

Calling it in my theme:

 

<? $reference = $this->driver->getScaRef(); if (!empty($reference)): ?>

<tr>

<th><?=$this->transEsc('Reference Number')?>: </th>

<td property="scaReference"><?=$this->escapeHtml($reference)?></td>

</tr>

<? endif; ?>

 

Path to theme template is: $VUFIND_HOME/themes/livuni/templates/RecordDriver/Emu/core.phtml

 

I have missed something obvious or are there any logs etc. which can point me in the right direction?

 

In addition, I would like to add this field to the Hierarchy Tree alongside the title. Is there a way to do this?

 

Thanks,

Joe

 

Joseph Schulkins | Systems Librarian | Libraries, Museums and Galleries | PO Box 123 | Liverpool L69 3DA | [hidden email] T 0151 794 3844

 

Follow us@LivUniLibrary   Like usLivUniLibrary   Visit ushttp://www.liv.ac.uk/library

Special Collections & Archives bloghttp://manuscriptsandmore.liv.ac.uk

Victoria Galleries and Museumhttp://vgm.liverpool.ac.uk

Garstang Museumhttp://www.liverpool.ac.uk/garstang-museum

 

ignature_808012961


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
VuFind-General mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/vufind-general
Loading...