divio / aldryn-search

Haystack 2.0 search index for django CMS
Other
48 stars 77 forks source link

Allow for #anchor in search results #90

Open tehfink opened 5 years ago

tehfink commented 5 years ago

Apologies if this has been addressed before, or if my thinking is off-base:

I have a plugin which returns a link to itself on a Page, e.g.:

def get_absolute_url(self):
        return f"{self.placeholder.page.get_absolute_url(language=self.language, fallback=False)}#{self.slug}"

It would be nice if the search results allowed for the plugin to override the Title's url, as otherwise the user must click the link, and then scroll/search to again find the plugin's text somewhere on the page. I think it could be accomplished by allowing the plugin to override the Title's get_url() here: https://github.com/aldryn/aldryn-search/blob/1f8c68aa6d7283d940e77d226bc9b5b9a17f2672/aldryn_search/search_indexes.py#L37-L38

Thoughts?