nbar
nbar

Reputation: 6158

Create the tx_news searchform in the layout

I would like to create the tx_news searchform on every page. So I try it to put it into the Layout:

<div class="news-search-form">
            <f:form object="{search}" name="search" pageUid="{settings.searchPid}">
                <fieldset>

                        <f:form.textfield id="news-subject" property="subject" class="form-control"/>

                        <f:form.submit class="btn btn-default search-button"/>
                </fieldset>
            </f:form>
        </div>

The problem is, that {search} is not defined when there is no searchplugin on the site.

When there is a searchplugin {search} looks like this:

Tx_News_Domain_Model_Dto_Search (prototype transient entity)
   subject => NULL
   fields => NULL
   uid => NULL
   _localizedUid => NULL
   _languageUid => NULL
   pid => NULL

Am I somehow able to create this directly in the layout or what would be the best way to have the searchform on every page?

Upvotes: 1

Views: 1052

Answers (2)

Oleg V Karun
Oleg V Karun

Reputation: 736

You can use direct TS easy

lib.blogsearch = USER
lib.blogsearch{
    userFunc = tx_extbase_core_bootstrap->run
    extensionName = News
    pluginName = Pi1
    switchableControllerActions {
        News {
            1 = searchform
        }
    }
    settings < plugin.tx_news.settings
    settings {
        listPid = #you_id

    }
}

Upvotes: 1

mtness
mtness

Reputation: 1024

Have you tried to insert the searchform via typoscript as records?

To do this, you should create the news plugin configured to search form somewhere in your pagetree, and reference it via ts like this:

lib.searchform = RECORDS
lib.searchform {
    wrap = (whatever)|
    tables = tt_content
    source = {id of the searchform CE}
}

This should do the trick.

Upvotes: 1

Related Questions