Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Search function doesn't work


Go to End


5 Posts   1283 Views

Avatar
alienn

Community Member, 15 Posts

19 August 2012 at 12:03am

Hi there
i'm creating search function to my simple site and.. no good.

i did everything like the tutorial and it seems that silvestripe ignores it.
First, search form displays

<form  id="SearchForm_SearchForm" action="/profil/SearchForm" method="get" enctype="application/x-www-form-urlencoded">

but i think it should be action="/results", because when i click id redirect me to that page (or similar like /something/SearchForm) and page just refresh, no search content it's displayed.
I've created results() function in Page_Controller, created Page_results.ss - everything what's on the tutorial, and still nothing.
I've just followed tutorial strictly, maybe i need to tweak it a little, but for now i'm stuck.

Someone can help me with this?

Avatar
Willr

Forum Moderator, 5523 Posts

19 August 2012 at 3:59pm

but i think it should be action="/results"

Nope, the form action goes to your controller which then redirects you after it's finished processing to the results uri. You shouldn't need to include any PHP code as that is all built in as of 2.4/3.0 though make sure your theme has a Page_results.ss template that outputs the results.

Avatar
alienn

Community Member, 15 Posts

22 August 2012 at 7:18am

ok thanks.
however its not working either.
clicking search button redirects me to "test.local/profile/SearchForm?Search=search&action_results=Ok"
and normal page is displayed, nothing more

Avatar
alienn

Community Member, 15 Posts

28 August 2012 at 7:42am

no one, really?

Avatar
(deleted)

Community Member, 473 Posts

28 August 2012 at 9:24am

Do you have a Page_results template, as per the tutorial?