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.

Template Questions /

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

Page control/function for getting current directory?


Go to End


2 Posts   2355 Views

Avatar
Samba Sam

Community Member, 85 Posts

24 November 2009 at 3:00pm

Edited: 24/11/2009 3:00pm

Hi,
I am customizing the $SearchForm.ss for my template. I need to get the current directory for calling up the action for the search form.

As in...
<form id="SearchForm_SearchForm" action="/currentdirectory/SearchForm" method="get" enctype="application/x-www-form-urlencoded">

Is there a page control for getting the current directory/page. If not, what would be the alternative (e.g., page controller function)?

Thanks,
Sam

Avatar
Samba Sam

Community Member, 85 Posts

25 November 2009 at 11:20am

Edited: 25/11/2009 11:21am

Hi,
I should have looked at the sapphire SearchForm.ss template before posting.

I got the search form working by using $FormAttibutes. The sapphire SearchForm template has some extra tags that I don't need (e.g., fieldset and legend).

So, I created a file SearchForm.ss with the following in the root of my template folder, which includes a bit of javascript to remove the "search" text when the search box is clicked on.

<form $FormAttributes >
<input type="text" name="Search" id="search" value="Search.." onfocus="if(this.value == 'Search..') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search..';}"/>
<input class="action" id="SearchForm_SearchForm_action_results" type="submit" name="action_results" value="GO" title="GO" />
</form>

And used $SearchForm in my page.ss template to call it up.

Sam