Jump to:

3431 Posts in 1025 Topics by 864 members

Template Questions

SilverStripe Forums » Template Questions » Page control/function for getting current directory?

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

Page: 1
Go to End
Author Topic: 1559 Views
  • Samba Sam
    Avatar
    Community Member
    85 Posts

    Page control/function for getting current directory? Link to this post

    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

  • Samba Sam
    Avatar
    Community Member
    85 Posts

    Re: Page control/function for getting current directory? Link to this post

    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

    1559 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.