SiteSearch

Adds global search capabilities to October CMS

Back to SiteSearch Support

jack21351
jack21351

Hi, I've been building a site and using the sitesearch plugin from the start. It's been working beautifully, but for some reason now it has simply stopped working. I get this error below. My site search is part of a "search page" layout and then I have written some text and things as a Static Page. The page works fine, but when a search query is attached to the URL, it breaks. I get this error:

Undefined index: title /var/www/vhosts/ccdevhub.com/octest.ccdevhub.com/plugins/offline/sitesearch/classes/providers/RainlabPagesResultsProvider.php line 30

    if ( ! $this->isInstalledAndEnabled()) {
        return $this;
    }

    foreach ($this->pages() as $page) {
        // Make this result more relevant, if the query is found in the title
        // line 30 // $relevance = $this->containsQuery($page->viewBag['title']) ? 2 : 1;

        $result        = new Result($this->query, $relevance);
        $result->title = $page->viewBag['title'];
        $result->text  = $page->parsedMarkup;
        $result->url   = $this->getUrl($page);

Last updated

jack21351
jack21351

I've even tried making the page as a standard page via the CMS pages method too. Same error occurs!

OFFLINE
OFFLINE

Hi

I am unable to reproducte this problem. What build of October are your running? What version of Rainlab.Pages is installed?

What is the output of a dd($page); inside the quoted code snipped above?

Last updated

jack21351
jack21351

Hi,

It's the latest October CMS version. It seems to break on some search terms but not others, here is the site (under construction) -> http://octest.ccdevhub.com/

I'm not sure what the output of a dd($page); is, sorry

Last updated

OFFLINE
OFFLINE

Can you add a dd($page) on line 29 so I can take a look at what data is available?

http://octest.ccdevhub.com/search?q=road

jack21351
jack21351

Sorry, I don't know what a dd($page) is? should I just add " dd($page) " to line 29?

jack21351
jack21351

Sorry, I don't know what a dd($page) is? should I just add " dd($page) " to line 29?

Update -- dd($page) now added to line 29

Last updated

OFFLINE
OFFLINE

You'll have to add a ; as well.

        foreach ($this->pages() as $page) {
            // Make this result more relevant, if the query is found in the title
            dd($page);
            $relevance = $this->containsQuery($page->viewBag['title']) ? 2 : 1;
jack21351
jack21351

Ok it's added to the script now :)

OFFLINE
OFFLINE

Can you replace it by $this->pages()? It looks like one of your static pages doesn't have the proper meta data saved and this is causing this problem.

   foreach ($this->pages() as $page) {
            // Make this result more relevant, if the query is found in the title
            dd($this->pages());
            $relevance = $this->containsQuery($page->viewBag['title']) ? 2 : 1;
jack21351
jack21351

Ok sure, I just did this in the script -->

foreach ($this->pages())

OFFLINE
OFFLINE

No, look at the snippet above. You have to leave the foreach but place $this->pages() inside the dd() call.

Last updated

jack21351
jack21351

Ok, sorry, its added now

OFFLINE
OFFLINE

Check your report-breakdown-immediate-coevr.htm static page. This page contains no data (title, content). If you don't need it anymore, make sure to remove it from your server (themes/xy/content) or open and save the page in your backend to make sure all necessary data is written.

You can remove the dd() statement from the plugin's code now.

jack21351
jack21351

ok sure, i have some pages that need removing that I am no longer using. Do you think that is what the issue was?

OFFLINE
OFFLINE

Yes I'm pretty sure. The plugin tries to search through the page's title but fails to do so if the page doesn't have a title...

jack21351
jack21351

Ah okkk I see, thank you so much for your fast support. Much appreciated!

zooks
zooks

I got this error after plugin update (v 1.3.3):

Undefined index: title RainlabPagesResultsProvider.php line 31

$relevance = $this->containsQuery($page->viewBag['title']) ? 2 : 1;

Last updated

zooks
zooks

zooks said:

Undefined index: title

I got this error because one of static pages didn't have [viewBag] section. But I think the plugin should handle the error.

OFFLINE
OFFLINE

This is fixed in 1.3.4. Thanks!

1-20 of 21