wintercms / wn-docs-plugin

Plugin that provides documentation direct to your Winter CMS installation.
MIT License
4 stars 9 forks source link

fix support search multiple documents #20

Closed wpjscc closed 4 months ago

wpjscc commented 1 year ago

fix when there are multiple documents, the search only supports one document。 because the table is Str::snake(Str::pluralStudly(class_basename($this)))

    /**
     * Get the table associated with the model.
     *
     * @return string
     */
    public function getTable()
    {
        return $this->table ?? Str::snake(Str::pluralStudly(class_basename($this)));
    }

modify to

    /**
     * Get the table associated with the model.
     *
     * @return string
     */
    public function getTable()
    {
        return $this->table ?? str_replace('.', '_', static::$pageList->getDocsIdentifier());
    }
}

other the Winter\Storm\Database\Traits\ArraySource , it only boot once , so the $arraySourceConnection is first document sqlite connect。

it need to clear the boot when have other document in Plugin.php

 MarkdownPageIndex::clearBootedModels();

 PHPApiPageIndex::clearBootedModels();

I think getTable is can not change when $arraySourceConnection is dynamic ,but it is not work when seach。

so modify getTable and clearBootedModels

bennothommo commented 1 year ago

If you're using the Nabu theme (which I believe you are), then yes, the search only supports the document type that's currently being viewed. However, you can modify the theme and override the search component implementation to search multiple document types if you prefer - the search component does support the ability to search multiple documents.

bennothommo commented 1 year ago

I don't believe using clearBootedModels is a good idea here either - that clears all booted models and prevents model caching from working.

wpjscc commented 1 year ago

If you're using the Nabu theme (which I believe you are), then yes, the search only supports the document type that's currently being viewed. However, you can modify the theme and override the search component implementation to search multiple document types if you prefer - the search component does support the ability to search multiple documents.

yes,the search component does support the ability to search multiple documents。I probably didn't express it clearly, In the process of using, when I switch to the second document, the search content is actually the first document,it may have some problems. after the above method is repaired,it work for me.clearBootedModels is not a good idea,Under research, a good method may be found.

bennothommo commented 1 year ago

@wpjscc could you provide an example of the issue so I can see what's happening? From the outset, I can't tell if it's a bug with the Docs or with the Search plugin.

bennothommo commented 4 months ago

We're going to close this for now - please comment if you wish to re-open.