I've created a custom next/previous function to modify the items/show.php page behavior depending on whether all items are being browsed, only the items from a particular collection, or the items resulting from a search. Adopting some of the suggestions on the forums, this generally seems to be working.
I would like to add an additional custom behavior when an item is being displayed from a link on my theme homepage's "Recent Items" list (but not of course when the same item is displayed from another context like a regular browse or search). I have not been able to understand yet how to detect this situation in my custom next/previous function or in items/show.php.
There would be a few ways to do this.
You could modify the links produced by the "Recent Items" list so they include some query-string parameter you can test for in the show page using
$_GET. That's probably the easiest way, but might require you to write some custom code for the "Recent Items" display.
You could also do something like check the HTTP referer header on the show page, and only do your additional behavior if the browser was previously on the homepage. This is a little more brittle solution, and might fail if the user has bookmarked the page, or on refresh, or if you have other ways to link directly to items from the homepage.
Thanks. I tried your first suggestion, and it works fine.