store_locator.rst 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. Store Locator
  2. =============
  3. The store locator provides pages for individual locations. These could be stores, distributors,
  4. facilities, etc. An index page aggregates these location pages using an interactive Google Map.
  5. The store locator is built-in to CodeRed CMS but is not enabled by default. To implement, add
  6. the following to your ``website/models.py``::
  7. from coderedcms.models import CoderedLocationIndexPage, CoderedLocationPage
  8. class LocationPage(CoderedLocationPage):
  9. """
  10. A page that holds a location. This could be a store, a restaurant, etc.
  11. """
  12. class Meta:
  13. verbose_name = 'Location Page'
  14. template = 'coderedcms/pages/location_page.html'
  15. # Only allow LocationIndexPages above this page.
  16. parent_page_types = ['website.LocationIndexPage']
  17. class LocationIndexPage(CoderedLocationIndexPage):
  18. """
  19. A page that holds a list of locations and displays them with a Google Map.
  20. This does require a Google Maps API Key that can be defined in Settings > Google API Settings
  21. """
  22. class Meta:
  23. verbose_name = 'Location Landing Page'
  24. # Override to specify custom index ordering choice/default.
  25. index_query_pagemodel = 'website.LocationPage'
  26. # Only allow LocationPages beneath this page.
  27. subpage_types = ['website.LocationPage']
  28. template = 'coderedcms/pages/location_index_page.html'
  29. Next run ``python manage.py makemigrations website`` and ``python manage.py migrate`` to create
  30. the new pages in your project.
  31. Now when going to the wagtail admin, you can create a Location Index Page, and child Location Pages.
  32. Also be sure to add a Google Maps API key under Settings > Google API Settings.
  33. .. note::
  34. Before creating or importing location pages, add your Google API key for automatic geolocation.