We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22730
    • 14 Posts
    I recently converted my site from Etomite to Modx. I love Modx but I have a small difference to figure out. I was running the easyPHPcalendar. This required putting PHP code in the template and body of pages.

    In MODx the PHP is not processed in teh template. I assume that al PHP must be in the form of a snippet or module. easyPHPcalendar requires the following statement in the head section.

    <?php $CSS=1; require("calendar/calendar.php"); ?>

    I tried putting this in as a snippet but so far no go. Any tips on how I can do this. I know its probably an easy solution but I’ve been away from PHP for awhile now.

    Thanks,
    terry
    http://216.70.102.151
      • 22815
      • 1,097 Posts
      Can you clarify

      1) did you end up with 2 snippets, one in the head and one in the body?
      2) which version of MODx are you using? (We have a beta of 0.9.5 available at the moment as well as 0.9.2, and there’s some changes to the way <?php is handled in a snippet).
        No, I don&#39;t know what OpenGeek&#39;s saying half the time either.
        MODx Documentation: The Wiki | My Wiki contributions | Main MODx Documentation
        Forum: Where to post threads about add-ons | Forum Rules
        Like MODx? donate (and/or share your resources)
        Like me? See my Amazon wishlist
        MODx "Most Promising CMS" - so appropriate!
        • 727
        • 502 Posts
        You can use a single snippet that outputs to a placeholder for the head section, so somewhere inside the head tags add:

        [+easyphpcalendarhead+]


        and then where you want the calendar call the snippet:

        [[easyphpcalendar]]


        Inside the snippet code output the piece that goes into the head to the easyphpcalendarhead placeholder.

        Andy
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          A snippet is php code and processed accordingly, therefore to "include" or "require" something you would just use
          $CSS=1; 
          require("calendar/calendar.php");
          return;
          

          You can use the snippet configuration to make configuration easier; for example:
          &CSS=CSS;int;1 &calPath=calPath;text;calendar/

          now you can easily set these to whatever values you want, and they’ll be used in the snippet.
          Then your snippet would look like:
          require ($calPath."calendar.php");
          return;
          

          (the return; probably isn’t really necessary, but it’s a good idea to always close out a snippet with one)
            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
            • 22730
            • 14 Posts
            Thanks a lot for the advice. I was able to get it working in 2 minutes once I read your posts. I se how I had the HTML <? tags which were killing the code. I removed the <? and everthing worked. I also added the return;

            If anyone is ever interested in easyPHPcalendar then here are 3 snippets to help the implementation. I will have more snippets when I finish the setup of my site. http://216.70.102.151

            Snippet: [[easyCalHead]]
            $CSS=1; 
            require("calendar/calendar.php");
            return;
            

            Snippet: [[easyCalBody]]
            $OL=1; 
            require("calendar/calendar.php");
            return;
            

            Snippet: [[easyCalImplement]]
            require("calendar/calendar.php");
            // SHOW LISTINGS MODULE
            // $epcListMouseover=1; // WILL USE THE MOUSE-OVER POPUPS FOR LIST MODE
                  $LIST=1;
                  $listEvents = 10;
                  $listWeeks=52;
                  $noOld = 1;
                  $DF = "M jS, Y (D)"; 
                  $template="modern.php";
                  require("calendar/calendar.php");
            return;
            

            Here is my template code if it matters
            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
            <html xml:lang="en-us" lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
            <head>
             <script type="text/javascript">
             <!--
             // Empty script to kill FOUC in IE
             // www.bluerobot.com/web/css/fouc.asp
             -->
             </script>
            
            [[MetaTagsExtra]]
            
             <style type="text/css">@import url(assets/templates/new-E/new-E.css);</style>
            
            {{CoolMenu}}
            [[easyCalHead]]
            </head>
            
            <body>
            [[easyCalBody]]
            
            
            <div id="bodyLiner">
            
            
            <div id="lwfHeader">
              {{MainBanner}}
            </div>
            
            <div id="lwfMenu">
                [[CoolMenu?type=horizontal&align=left&top=180&left=0&arrow=0&width=126&height=25]]
            </div>
            
            <div id="lwfBanner">
                  <img src="assets/images/banners/takegodsmall.jpg" alt="Take God at His Word" border="1"/>
                   <hr>
            </div>
            
            
            <div id="lwfContent">
                     
                   [*content*]
            
            </div>
            
            <div id="lwfSideCol">
            [[easyCalImplement]]
            </div>
              
            
            <div id="lwfFooter">
              <p>[!Copyright!] | [[PoweredBy]]</p>
              <p>MySQL: [^qt^], [^q^] request(s), PHP: [^p^], total: [^t^], 
                document retrieved from [^s^].</p>
            </div>
            
            
            </div>
            </body>
            </html>


            [MODERATOR’S NOTE: Code tags added for easier readability.]