I have a database with many vacation rental properties accross the us. I created a dynamic page that displays the properties in a specific city. When I go to the dynamic page for something like “/properties/Boston/MA/US” and I have properties there, the page pulls up fine and displays the properties. However, if I don’t have properties in the database for a specific city and the visitor goes to that page like “/properties/Dallas/TX/US” then a I get a “Page does not exist error”. What I would like to do is to display the city page but just show a message that says “No properties found. Add your property”. I’m assuming this can be accomplished with hooks, but just not sure exactly what type of hook. If someone could give me a little direction on this that would be great. Thanks.
How do people get to a property which doesn´t exist? Maybe you should solve it there. It is impossible to have code or whatever in non-existing pages.
Wix has only recently added custom 404 pages, and I don’t think you can have more than one at the moment. To create a custom 404, you need first a premium account, and then simply create a page called error404 . You can add whatever text you’d like there.
I’m not attempting to create a property page for a property that does not exists. The dynamic page is a city page that display properties. Some cities may not have properties at this time but I still want to have a link on the homepage to that city page. However before the wix system attempts to create the dynamic city page I would like to check to see if there are properties in that city and if not redirect to a dynamic page that will just display “No properties found in Dallas” and then the visitor will have the opportunity to add a property from there. I hope that makes sense. This also does not have anything to do with a error404 page.
@dskinner The ‘wix system’ doesn’t create pages, and these cities will only have a dynamic page assigned to them if you have created a backend snippet that inserts these cities into a database based off of some list of cities you feed it. Otherwise if a user attempts to access a URL with this path and it doesn’t exist, they will always see a 404.
If you are talking about functionality for a search page, that’s a different question entirely.
@skmedia I think I was just wording it incorrectly. I realized after looking at how the routers work that I could use the afterRouter function to accomplish what I’m trying to do which is send the user to a generic page (when no results were found) and dynamically fill in the text elements with the data from the response. Thanks for responding, it’s much appreciated.
@dskinner Sure thing, although I would recommend adding this text/response to your search results page instead of adding a router. It can help improve your user’s experience in case they have a slow connection. The fewer redirects the better.
@skmedia Thanks for the recommendation David.
Trying to do exactly what you are doing. Did you find a way to make this work for you? I tried using the before router functionality but it kept throwing the 404.