Tom
Tom

Reputation: 119

Insert TypoScript Object into HMENU

TYPO3 v 7.6.13 Indexed_search 7.6.0

I’m generating a typical drop menu using TYPOScript.

And I’m appending a list item at the end that contains a drop menu for a search box.

I’m using indexed_search and I have a separate Typoscript Oject setup called lib.search.

In my typoscript that generates my drop down menu, how can I reference / insert lib.search and have it inserted into my drop down menu.

This is my search TS,

lib.mainNavi = HMENU
lib.mainNavi.wrap (

<div class="navbar navbar_custom" role="navigation" aria-label="Main Navigation">

    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
 <a class="navbar-brand" href="#">My Site</a>
    </div>
    <div class="collapse navbar-collapse" id="navbar-collapse">
<ul class="nav navbar-nav">|<li class="dropdown"><a href="#" class="dropdown-toggle glyphicons glyphicons-search" data-toggle="dropdown"></a><ul class="dropdown-menu col-md-12 col-xs-12 dropdown_grd"><li>
    <input type="text" class="searchText" placeholder="Search for..."/>
    <input type="button" class="searchButton" id="navSearchButton"/>

**search TSO goes here{lib.searchheader}**

</li></ul></li></ul>
    </div><!-- /.navbar-collapse -->
</div>

  )

And this is the TS that generates my search box.

lib.searchheader = COA_INT
lib.searchheader {
  10 = TEXT
  10.typolink.parameter = {$plugin.tx_indexedsearch.searchUID}
  10.typolink.returnLast = url
  10.wrap = <ul><li>|</li></ul>
}

When I reference lib.search I only get text when the page is rendered:

{lib.searchheader}

Upvotes: 0

Views: 422

Answers (1)

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10791

if you want another TS-object to be inserted at a special position, enable your TS to insert something there.
Either you use a wrap or you can use a COA.

in your example the wrap is way to big and you can't wrap two different contents. so my attempt would be to split up your wrap in a COA:

lib.mainNavi = COA
lib.mainNavi {
    wrap = <div class="navbar navbar_custom" role="navigation" aria-label="Main Navigation"> | </div>

    // intro
    10 = TEXT
    10.value (
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">My Site</a>
        </div>
     )

     //outer-wrap of menu
     20 = COA
     20 {
         wrap ( 
            <div class="collapse navbar-collapse" id="navbar-collapse">
              <ul class="nav navbar-nav">
                 |
              </ul>
            </div><!-- /.navbar-collapse -->
         )

         // the real menu    
         10 = HMENU
         10 {
            :
         }

         // additional search entry:
         20 = COA
         20 {
            wrap (  
               <li class="dropdown">
                  <a href="#" class="dropdown-toggle glyphicons glyphicons-search" data-toggle="dropdown"></a>
                  <ul class="dropdown-menu col-md-12 col-xs-12 dropdown_grd">
                     <li>
                        <input type="text" class="searchText" placeholder="Search for..."/>
                        <input type="button" class="searchButton" id="navSearchButton"/>
                        |
                     </li>
                  </ul>
               </li>
            )

            10 < lib.searchheader      
         }
     }     
 }

And be careful mixing USER and USER_INT objects. (never cascade USER_INT inside USER_INT)
Those uncached objects are stored with a placeholder similar to a fluid-variable with a hash-name. They will be evaluted/resolved at run time.

are you sure your lib.searchheader needs to be an COA_INT?

Upvotes: 1

Related Questions