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:connecting_a_new_external_data_source

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
development:howtos:connecting_a_new_external_data_source [2023/03/27 19:20] – [7. Register Controllers] demiankatzdevelopment:howtos:connecting_a_new_external_data_source [2023/06/19 18:21] (current) – [6. Create Controllers] demiankatz
Line 59: Line 59:
 In order to provide web access to your new code, you will need to create two new controllers in the module/VuFind/src/VuFind/Controller folder (or in an equivalent place in your local module): In order to provide web access to your new code, you will need to create two new controllers in the module/VuFind/src/VuFind/Controller folder (or in an equivalent place in your local module):
     - **Search Controller** - This should have a name like \VuFind\Controller\SampleController and should extend \VuFind\Controller\AbstractSearch.  This controller will handle displaying and processing search forms.  At a bare minimum, it should contain a constructor which sets the $this->searchClassId property to the appropriate value (i.e. 'Sample') and calls the parent constructor.  You can look at the \VuFind\Controller\AbstractSearch class for other available options.  You can also define controller actions if you wish, but this is not necessary -- by default, you will have Home, Results and Advanced actions inherited from the base class.     - **Search Controller** - This should have a name like \VuFind\Controller\SampleController and should extend \VuFind\Controller\AbstractSearch.  This controller will handle displaying and processing search forms.  At a bare minimum, it should contain a constructor which sets the $this->searchClassId property to the appropriate value (i.e. 'Sample') and calls the parent constructor.  You can look at the \VuFind\Controller\AbstractSearch class for other available options.  You can also define controller actions if you wish, but this is not necessary -- by default, you will have Home, Results and Advanced actions inherited from the base class.
-    - **Record Controller** - This should have a name like \VuFind\Controller\SamplerecordController and should extend \VuFind\Controller\AbstractRecord.  This controller will handle displaying records and performing record-related tasks (export, save, etc.).  At a bare minimum, it should contain a constructor which sets the $this->searchClassId property to the appropriate value (i.e. 'Sample') and calls the parent constructor.+    - **Record Controller** - This should have a name like \VuFind\Controller\SamplerecordController and should extend \VuFind\Controller\AbstractRecord.  This controller will handle displaying records and performing record-related tasks (export, save, etc.).  At a bare minimum, it should contain a constructor which sets the $this->sourceId property to the appropriate value (i.e. 'Sample') and calls the parent constructor.
  
 ====7. Register Controllers==== ====7. Register Controllers====
Line 68: Line 68:
     - In the $recordRoutes array, add an association between the route name (which should be your source value concatenated with the word "record") and the route's controller name (as registered in controller invokables above).  For example: 'samplerecord' => 'samplerecordcontroller'     - In the $recordRoutes array, add an association between the route name (which should be your source value concatenated with the word "record") and the route's controller name (as registered in controller invokables above).  For example: 'samplerecord' => 'samplerecordcontroller'
     - In the $staticRoutes array, add any necessary search-related routes... for example, 'Sample/Home', 'Sample/Search' and 'Sample/Advanced'.     - In the $staticRoutes array, add any necessary search-related routes... for example, 'Sample/Home', 'Sample/Search' and 'Sample/Advanced'.
-    - Note that, if you are using a [[development:architecture:customizing_vufind#modules|custom module]], you may need to copy some extra route-building logic from the main VuFind® configuration, since these convenience route-building arrays are not present by default in empty modules+    - Note that, if you are using a [[development:architecture:customizing_vufind#modules|custom module]], you may need to copy some extra route-building logic from the main VuFind® configuration or use a [[development:code_generators|code generator]], since these convenience route-building arrays are not present by default in empty modules
  
 ====9. Set Up Templates==== ====9. Set Up Templates====
 Now that the models and controllers are set up, you need some views. Now that the models and controllers are set up, you need some views.
     - //Search Templates// - Within your chosen theme, create a templates/sample directory (replacing 'sample' with a lowercased version of your search controller's name).  In this directory, you need to create one template for each action: advanced.phtml, home.phtml and search.phtml.  These templates can simply wrap around the default search templates, overriding a few settings if necessary.  See the existing templates in templates/worldcat for the simplest possible example.     - //Search Templates// - Within your chosen theme, create a templates/sample directory (replacing 'sample' with a lowercased version of your search controller's name).  In this directory, you need to create one template for each action: advanced.phtml, home.phtml and search.phtml.  These templates can simply wrap around the default search templates, overriding a few settings if necessary.  See the existing templates in templates/worldcat for the simplest possible example.
-    - //Record Templates// - If your record driver extends \VuFind\RecordDriver\SolrDefault, you may not need to create any record templates at all -- the defaults should work for you.  However, if you built a custom driver, you will need to create an appropriately-named directory under templates/RecordDriver in your chosen theme.  Look at the existing templates in templates/RecordDriver/SolrDefault to see which filenames you need to create and what sort of content they should contain (note that some are optional and some filenames are dynamically generated based on other record driver options -- i.e. the tab-*.phtml files, which are driven by allowed tab options).+    - //Record Templates// - If your record driver extends \VuFind\RecordDriver\DefaultRecord, you may not need to create any record templates at all -- the defaults should work for you.  However, if you built a custom driver, you will need to create an appropriately-named directory under templates/RecordDriver in your chosen theme.  Look at the existing templates in templates/RecordDriver/DefaultRecord to see which filenames you need to create and what sort of content they should contain (note that some are optional and some filenames are dynamically generated based on other record driver options -- i.e. the tab-*.phtml files, which are driven by allowed tab options).
 ---- struct data ---- ---- struct data ----
 properties.Page Owner :  properties.Page Owner : 
 ---- ----
  
development/howtos/connecting_a_new_external_data_source.1679944837.txt.gz · Last modified: 2023/03/27 19:20 by demiankatz