Return site's URL by site_id that item is associated with

Hi there,

I am wondering if anyone would know how to programmatically return the URL of a site by the site_id of which a certain item is associated with that site. The idea is to dynamically link each item with its associated site pool.


So, do you already have the site_id, or do you need to get it? If you have the site ID you need, then you can get the site from the API and get its URL.

If you’re trying to dynamically get which site the item is in by examining the pools, that’s a little trickier. We’re considering some changes in this area for a future release, actually.

1 Like

Yes, I’m trying to dynamically get which site an item is from and displaying the link for users to click on and visit. I basically want to create a keyword item search from our “umbrella” site that houses all of our sites, and with the results, a user can click into the item and see the normal information, but also see which site it’s associated with so they can go learn more about that site.

Of course this can be done manually by putting in a URL in the item’s “relation” field, but who wants to do that for 600+ items? lol.

I’m trying to figure out how to do this by looking at some code in the site-pool.phtml and try to implement something custom in the item’s show, but I am stuck at the moment.

I’m trying to develop a case for our institution to keep using Omeka S as a primary digital platform and developing functions such as this would really help that case :slight_smile:

How are you setting up your site pools? If it’s something like item sets or some unique metadata value that’s assigning to each pool, you could just use that same information to determine the site for each item… this is basically re-encoding the pool assignments into the theme. For these pretty simple pool definitions that can be done without too much trouble and will be fast.

In the more general case where the pool definitions are more complex, there’s no way to know which site(s) an item is in the pool of without just running the pool query for each site. With few enough sites this can be not too bad performance-wise, but it will scale poorly with larger numbers of sites.

As I said in an earlier post, we’re looking at making some changes that will enable this kind of thing to work more “out of the box,” making it so that we can easily and quickly get a list of which site(s) any particular item is in.

The bulk editor is possibly a reasonable option for you as well: you can do a search for items that are in a site’s pool and assign the same value to all of them at once.

1 Like

Ok, this helps. I tried using the bulk editor to assign a URI value of its website (or particular page in the website I want visitors to go back to) for several items and it wasn’t so bad. Thanks for the tip!