Sign Up for OSTraining

Welcome, Guest
Username: Password: Remember me

TOPIC: Search results includes unpublished content

Search results includes unpublished content 10 months 2 weeks ago #51018

  • careytech
  • careytech's Avatar
  • OFFLINE
  • OSTycoon
  • Posts: 236
  • Karma: 0
My client reports that a the search feature I recently added is pulling in unpublished content. Is a filter or setting to have the search include only those items that are published during the time of the search?

When I go to the Smart Search component, I see a long list of documents that have been indexed, and all are published. And I see some yes-no options under the "search" plugins for Content, K2, etc - but the descriptions for these options are not always clear.

So do you have a recommendation as to how have unpublished content always filtered out of the results for smart search?
Please become a member of OSTraining to reply to this post.

Search results includes unpublished content 10 months 2 weeks ago #51049

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
Hi,

I just tried this on a test site, by unpublishing all the articles then doing a search. When I search, It finds the articles, but when I click on one of the links I get a page not found.

So the article title and link show, but nobody should be able to see the actual article.

If you don't want the links to show at all, you would need to go into the module view template and change the logic to so that if the status was unpublished, the module would not display any results.

Do you know enough about php to do that?

Ed
Please become a member of OSTraining to reply to this post.

Search results includes unpublished content 10 months 2 weeks ago #51053

  • careytech
  • careytech's Avatar
  • OFFLINE
  • OSTycoon
  • Posts: 236
  • Karma: 0
Thanks Ed. Yes, I do that sort of overriding fairly often. It's usually something like adding this line of code at the start of the loop...
if(!$item->published) continue;

Of course, this seems to be something that should be default behavior, and the option to include unpublished (if there is a reason to do it) should be built in as a configuration option.

Unless I hear that there is such an option setting, I will override the view accordingly.
Please become a member of OSTraining to reply to this post.

Search results includes unpublished content 10 months 2 weeks ago #51056

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
I agree. It seems pretty obvious. But it's a new feature and I don't think it has matured quite yet. We'll see what happens when 3.0 comes out.

Cheers,
Ed
Please become a member of OSTraining to reply to this post.

Search results includes unpublished content 10 months 2 weeks ago #51079

  • careytech
  • careytech's Avatar
  • OFFLINE
  • OSTycoon
  • Posts: 236
  • Karma: 0
More to say on this...

I found that the loop that displays the search results seems not to produce a $result item that has a published-vs-unpublished field. And I didn't find any discussion of this topic through a Google search.

But as I conducted my own testing, I'm finding that unpublished items are not showing in the results. I can toggle an Article between published and unpublished, and it appears or is absent as I would expect. So I asked my client and the example he gave me is for an article that is "published" in the Joomla sense, but not connected to any navigation or links within the site.

Ed, now I'm confused as to what you experienced. I'll have to guess that you have some caching going on, and the site I'm testing is in development and does not have caching on. That's my best guess. Anyway, I want to believe that search does not include the unpublished content - and that those developing that feature designed it that way.
Please become a member of OSTraining to reply to this post.

Search results includes unpublished content 10 months 2 weeks ago #51098

  • edandrea
  • edandrea's Avatar
  • OFFLINE
  • OSTop Dog
  • Posts: 3106
  • Thank you received: 7
  • Karma: 0
What happened to me is almost what happened to your client, but a slight twist.

I unpublished all my articles, then did search for the word "module"

None of the articles were found, but I did have a menu item with the word module in it. It found the menu item and showed the link to the category, but gave me a page not found error when I visited the link.

It looks like if you search for a word that is also in a menu item title it will find the link title, and show the link. But of course there is nothing published there.

I left the articles unpublished. You can try it for yourself by going to dashhelp.com and use the search box to search for the word module.

Sorry about that. I happened to pick a search word that was in the article and in the menu item. If I had picked anything else I wouldn't have got any search results.

Ed
Please become a member of OSTraining to reply to this post.

Sign Up for OSTraining

Powered by Kunena Forum

Open Source Training is not affiliated with or endorsed by the Joomla, WordPress or Drupal projects.
All product names and trademarks are the property of their respective owners.

Copyright 2013 Open Source Training, LLC. All rights reserved.