We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26928
    • 3 Posts
    I’m trying to make a search tool come up in the header bar of a certain page but none of my attempts so far have worked.

    So far I have tried to:
    -use a php if statement
    -use a phx if statement
    -investigate template variables

    I always seem to get stuck on simple things like this sad
      • 3749
      • 24,544 Posts
      Any of those methods should work.

      In order to help you, we need to know what the search tool is and see the code you used to try to put it on the page. smiley
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 26928
        • 3 Posts
        It’s the search widget for my ecwid shop although I’m thinking of ditching ecwid.

        <?php
        if([*pagetitle*] == "Products")
        {
            echo '<div>
                <script type="text/javascript" src="http://app.ecwid.com/script.js?98174" charset="utf-8"></script>
                <script type="text/javascript"> xSearchPanel("style="); </script>
                </div>';
        }
        ?>
        


        [+phx:if=`[*pagetitle*]`:is=`Products`:then=`<div>
        <script type="text/javascript" src="http://app.ecwid.com/script.js?98174" charset="utf-8"></script>
        <script type="text/javascript"> xSearchPanel("style="); </script>
        </div>`+]
        
          • 3749
          • 24,544 Posts
          The PHP code would be much more efficient, but it would have to go inside a snippet. Use "return" instead of "echo" and put the snippet tag where you want the js code to appear.


            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 4310
            • 2,310 Posts
            <?php
            if($modx->documentObject['pagetitle'] == "Products")
            {
            return '<div>
                    <script type="text/javascript" src="http://app.ecwid.com/script.js?98174" charset="utf-8"></script>
                    <script type="text/javascript"> xSearchPanel("style="); </script>
                    </div>';
            }
            ?>
              • 26928
              • 3 Posts
              cool, that works thanks