Jump to:

794 Posts in 408 Topics by 304 members

Widgets

SilverStripe Forums » Widgets » SearchForm in a widget?

Discuss SilverStripe Widgets.

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

Page: 1
Go to End
Author Topic: 705 Views
  • JosefBlow
    Avatar
    Community Member
    1 Post

    SearchForm in a widget? Link to this post

    Hi all,

    I'm trying to add a blog search tool using some code which I've found in one of my old site implementations (I've no idea where I found this code or if it ever worked?!).

    I have the following files..

    SearchWidget.php

    <?php

    /**
    * A simple widget that just shows a search box
    * @package blog
    */
    class SearchWidget extends Widget {
       
       static $title = 'Search';
       
       static $cmsTitle = 'Blog Search';
       
       static $description = 'Shows a search option on the sidebar. This feature uses the standard site search module, so ensure that all other pages have "Show in search?" disabled unless you wish for those pages to feature in the search results.';

       /**
        * Return an absolute URL based on the BlogHolder
        * that this widget is located on.
        *
        * @return string
        */
    }

    ?>

    and
    SearchWidget.ss

    <ul>
    <li>$SearchForm</li>
    </ul>

    The widget is happily available with the Blog module of the CMS, but after nudging around in various directions, I've just hit a wall and can't get it to run.
    I'm running SS v2.4.5 and I've enabled search with FulltextSearchable::enable();
    I can also call $SearchForm from within another template eg. Page.ss succesfully.

    Anyone got any ideas? I'm stumped!

    Thanks in advance...

    705 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.