Using PHP for DSpace content in Wordpress?

364 views
Skip to first unread message

Chris Clawson

unread,
Jan 17, 2022, 12:27:34 PM1/17/22
to DSpace Technical Support

I am trying to populate a Wordpress page with DSpace content, directly from my own repository on the same server. I have a demo of this idea at https://montaguearchive.org/index.php/hurricane-of-1938-page-3/ . This example uses a php script to read a server side list of URIs I wish to place in a gallery. It then uses CURL to make web calls to these links, extract the information and then populate a web page in Wordpress.

Might someone please help in achieving this by using direct queries to DSpace's postgresql database?

I am attaching a demo script based on the information at https://wiki.lyrasis.org/display/DSPACE/The+metadatavalue+table .

When I edit this script to match my DSpace db login and use an 'id' (from an exported metadata .csv), it will execute and echo the dc.contributor.author of this item inside a terminal shell. Try this only if you have installed the proper php module which allows a login to your database. In my case, it was php7.1-pgsql.

Is there better documentation somewhere which hints or explains how to use the DSpace tables in a direct SQL query? Are there human readable forms in the DSpace installation files, which would hint at some of these methods?

Might someone provide specific examples, based on this script I have provided?

Using an exported csv as a reference, I need to build queries for these specific terms (using the 'id' of an item in the csv column 1):

dc.description

dc.identifier.uri

dc.title

----** and importantly, how may an image bitstream be retrieved in a manner which can be placed in a web page?

I really believe this technique may help promote DSpace by making it easier to create visual galleries and presentations in Wordpress (or other) websites. DSpace is an incredible resource for creating and managing repositories, but really should have an easier way to present it's content to an audience interested in casual browsing or authored presentations. My web visitors are just not motivated when I tell them “go and explore the database”.

Please help.,

Chris




dspace.php

Fitchett, Deborah

unread,
Jan 17, 2022, 3:48:57 PM1/17/22
to Chris Clawson, DSpace Technical Support

Do you need to use direct queries to the database? Even if you are on the same server it might be simpler to use the REST API (see documentation at https://wiki.lyrasis.org/display/DSDOC7x/REST+API) and if you ever might split the Wordpress site onto a different server it would be more robust.

 

Other options (probably not as good, but included for completeness) might be to call an OAI feed (would work best by collection and/or by date - https://wiki.lyrasis.org/display/DSDOC7x/OAI) or OpenSearch (can work via keyword queries - https://wiki.lyrasis.org/display/DSDOC7x/Business+Logic+Layer#BusinessLogicLayer-OpenSearchSupport).

 

Deborah

 

From: dspac...@googlegroups.com <dspac...@googlegroups.com> On Behalf Of Chris Clawson
Sent: Tuesday, 18 January 2022 6:28 AM
To: DSpace Technical Support <dspac...@googlegroups.com>
Subject: [dspace-tech] Using PHP for DSpace content in Wordpress?

 

Caution: This email originated from outside our organisation. Do not click links or open attachments unless you recognize the sender and know the content is safe.

 

--
All messages to this mailing list should adhere to the Code of Conduct: https://www.lyrasis.org/about/Pages/Code-of-Conduct.aspx
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/6dc88382-5ac6-480f-a1e2-2d0f3f849fdan%40googlegroups.com.




"The contents of this e-mail (including any attachments) may be confidential and/or subject to copyright. Any unauthorised use, distribution, or copying of the contents is expressly prohibited. If you have received this e-mail in error, please advise the sender by return e-mail or telephone and then delete this e-mail together with all attachments from your system."

Chris Clawson

unread,
Jan 17, 2022, 4:02:16 PM1/17/22
to DSpace Technical Support
Yes, that might be a better way to go! I have never tried to make queries directly from the Rest back end, but I had better start reading on it and see if I can understand what is written. With the Wordpress page making calls to a server side PHP script, it should be an easy matter to communicate with the localhost service running at port 4000. Of course, 'easy' is a relative term. It would be very helpful if anyone wished to offer some demo snippets of how this might be started. Thanks for getting my mind to look in an obvious direction.

Fitchett, Deborah

unread,
Jan 17, 2022, 10:30:41 PM1/17/22
to Chris Clawson, DSpace Technical Support

I’ve only interacted with DSpace’s RESTful interface via another software integration so can’t help much. But I *think*(1) that if you’re only dealing with open access collections anyway, then you mightn’t need to worry about any authentication stuff at all, and then you can probably just make a bunch of cURL GET requests which it sounds like you’re already familiar with.  (Plus some json_decode functions, see the PHP manual if needed there.)

 

Deborah

(1)    Ie I’m too lazy to double-check but am pretty sure I made some browser-based GET calls without authenticating at some point.

Reply all
Reply to author
Forward
0 new messages