We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3293
    • 8 Posts
    hi,
    i want to include a php file but it doesnt works.

    i have a php file named sidebar.php inside assets/templates/mytemp001/ .
    From modx manager ive created a snipped named mysidebar which has following codes:
    <?php
    include("assets/templates/mytemp001/sidebar.php")
    ?>


    then in my site template i added following after <p>[*content*] </p>
    [*mysidebar*]

    Now when i open my site, the sidebar part is not appearing.

    sidebar.php contains some links of external sites.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Snippets use [[...]] tags, or [!...!] if you don’t want the snippet output cached (for instance, forms can’t be cached since the page needs to run the snippet again on submission to process the form).
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 3293
        • 8 Posts
        thanks very much
          • 3293
          • 8 Posts
          Quote from: sottwell at Jul 01, 2009, 09:49 AM

          Snippets use [[...]] tags, or [!...!] if you don’t want the snippet output cached (for instance, forms can’t be cached since the page needs to run the snippet again on submission to process the form).

          i tried changing from [*mysidebar*] to
          [[mysidebar]]
          and even [!bickysidebar!]
          but it doesnt works, no errors nothing

          may be something to do with the code: <?php
          include("assets/templates/mytemp001/sidebar.php")
          ?>


          include link file works directly by using www.mysite.com/assets/templates/mytemp001/sidebar.php
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            Your snippet already has <?php and ?> tags. You will also need to adjust your external code to return something, and then in your snippet return it. For example, put your code’s output into a variable, then end your snippet with return $variablename;
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 3293
              • 8 Posts
              it worked now: i changed php include to this

              <?php
              include "assets/templates/bblog2/resources/sidebar.php";
              ?>


              thanks sotwell