We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2396
    • 101 Posts
    Hi,

    Is it possbile to show two different ’Search box texts’ on the one site?

    E.g. on my main site I’d like to have "Search website..." but on my blog (in a subdirectory) I’d like "Search blog..." (because I only want to search blog articles and not the main site). At the moment it has the same text because in my snippets/ajaxSearch/lang/english.inc.php file I have:

    $_lang['as_boxText'] = 'Search website...';


    Is it maybe possible to refer to different language files (or in a chunk) from the snippet call?
      • 26016
      • 561 Posts
      Hi,
      Yes, you can. It’s a bit of a pain. I remember trying to use parms in my call to get this to work - there is one that supposedly works for this. Various people at various times gave ways that it worked, but it seems that with every update of Ajaxsearch, something becomes deprecated. Surprise! So that didn’t work for me.

      And like you, I dug until I found that language file. But when you update MODx (or Ajaxsearch itself), and boom, your change in the language file is borked, so you have to go back in and change it again when your client says, "why did my Search change?" smiley

      There is a reliable way to do this, though, and it will survive an upgrade. You replace the default template for the search.

      You’ll need to do some digging... check out the contents of this folder:
      assets/snippets/ajaxSearch/templates/input.tpl.html

      You can copy this code into a chunk, modify it, and then use this parm in your call:

      &tplInput=`YourSearchChunkHere`


      Another benefit of templating is that you can better control CSS styling of your forms, which is always a chore. I hope this saves you the time that I lost hunting this down.

      Cheers, Dave
        MODx and Wordpress development
        Linux, PHP 5.2, MySQL 5.0, Evo 1.05, Revo 2.08-pl, Firefox 4
        • 2396
        • 101 Posts
        OK, that works, so simple – thanks a lot. I had been trying something with templates but I think I was overcomplicating it... again.

        And I also had to remember to add clearDefault=`1` to the snippet call to clear both the input texts, as it only seemed to clear for the one with the exact same input text specified in the language file.