ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Get previously viewed page's entry ID

October 01, 2011 6:48pm

Subscribe [2]
  • #1 / Oct 01, 2011 6:48pm

    Eric Nance

    25 posts

    My client has an interactive map on their site which uses javascript and css to build the map and style the effects:

    http://rockvilletownsquare.com/map

    We have a custom field that holds the tenant map location and use javascript to pass that info to the map.

    The client would like the map to highlight the tenant on the map if they clicked to the map from a listing on the Restaurants & Cafes page or the Shops & Services page. For example, if you’re viewing Five Guys Famous Burgers and Fries:

    http://rockvilletownsquare.com/restaurants-and-cafes/five-guys-famous-burgers-fries

    then click on Interactive Map at the lower right they would like Five Guys Burgers and Fries to be highlighted on the map.

    I figure I could use document.referrer to get the previously viewed URL. But I’m stuck after that. What would be a good way to convert that last segment in the referring URL to the entry ID? Once I have that, I think I could query the database to find the custom field value for that entry.

    Any help would be appreciated.

  • #2 / Oct 02, 2011 6:54am

    John St-Amand

    865 posts

    You could simply push the entry Id or the entry’s URL title into the last segment and grab it from there to temporarily highlight the location they linked to the map from. Then the map URL in that case would be something like http://rockvilletownsquare.com/map/five-guys-famous-burgers-fries - though I realize that might potentially affect the map functionality for the user’s next click.

  • #3 / Oct 02, 2011 9:59am

    Eric Nance

    25 posts

    Thanks for the tip John. Seems like a simple solution that probably would work. Can’t believe that one escaped me…

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases