We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32025
    • 305 Posts
    I am using MODx Revolution v2.2.6 and I am nesting a PHP program into my MODx. This program has it's own database and runs i'ts own site. I can then nest this separate program inside MODx using Namespaces and actions. I have already done this with 2 other programs and it works great. The problem that I am having is my templates are in HTML and the new program wants me to add includes onto a PHP page. My master HTML template look like this:
    <!DOCTYPE html>
    <head>
    <meta charset="utf-8">
    <title>My Website</title>
    <link href="mystyles/style.css" rel="mystylesheet" type="text/css">
    </head>
    
    <body>
    
    <div id="page">
    	<div id="logo">
    		[[$logo]] </div>
    		<!-- menu start -->
    			<div id="nav">[[$navigation]]</div>
    		<!-- menu end -->
    				<div id="content">[[*content]]</div>
    					<div style="clear: both;"></div>
    				
    			<img class="graybar" alt="logo_banner" height="5" src="images/bg_banner_grey.gif" width="930" />
    	<div id="footer">[[$footer]]</div>
    </div>
    		
    </body>
    
    </html>
    


    The software I am trying to implement has these instructions:
    Step 1: Copy the code below and paste it at the top of your PHP page.
    
    <?php
    ob_start();
    ?>
    
    Step 2: Copy the code below and paste it within the HEAD tag of your page.
    
    <script type="text/javascript" src="http://www.MySite.com/core/components/forum45/app45/jabb-0.3.js"></script>
    <script type="text/javascript" src="http://www.MySite.com/core/components/forum45/app45/sforum.js"></script>
    <link href="http://www.MySite.com/core/components/forum/app45/front.css" type="text/css" rel="stylesheet" />
    
    Step 3: Copy this code and paste it where you want the forum to appear.
    
    {JKFORUM45_TPL}
    
    Step 4: Copy this code and paste it at the very bottom of your PHP page.
    
    <?php
    require_once "/MyRoot/core/components/forum45/gmain.php";
    ?>
    


    Obviously the script wants me to put this coding into a PHP page. Steps 1 and 4 above are the problem I can implement step 2 and 3 into my current HTML template. My templates serve up HTML pages. I have several other scripts from this same maker and all those have an add to header tag and body tag, they work well with HTML pages. This script seems to want to only work with PHP pages (Given Step 1 and Step 4).

    Is there a solution so I can show these PHP template variables directly into my HTML template? I am not real familiar with PHP, but have changed HTML pages to PHP in the past just by renaming. So I wouldn't know how to do this or if it would even work. Any ideas as to how to get these to work together? I am baffled as how to approach this.
      Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
      • 37946
      • 70 Posts
      Well, you could literally create a snippet...

      [[obStart]]
      <?php
      ob_start();
      ?>
      


      [[gMain]]
      <?php
      require_once "/MyRoot/core/components/forum45/gmain.php";
      ?>
      



      So, your template would look something like:

      [[obStart]]
      <doctype>
      <html>
      
      <stuff.../>
      
      [[gMain]]
      </html>
      


      Hope this helps!


        • 32025
        • 305 Posts
        Jentree thank you for your help. When I added each of the codes in the snipplets, the snipplet save was stripping the PHP tags. The last part of the tags in particular (?>) and sometimes the first part of the tags (<?php) depending on how many times I tried to save each snipplet. I also thought adding PHP to my pages might be a problem because I do have friendly URL's enabled. A few times I got the invalid syntax error pages after saving and adding the snipplets to my template like you recommended (obviously because the PHP tags were being stripped)

        There was a work-around with the software it had an HTML preview page. I added this preview page to an iFrame and this is how I was able to get it to work. The software company responded after the fact and let me know it was the correct way to implement.

        Wish I didn't have to have the iFrame it hurts as Google will not see the content (which was the reason for the forum to begin with), but it will work I guess.
          Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
          • 3749
          • 24,544 Posts
          MODX strips PHP opening and closing tags, but the code in the snippet is all executed within PHP.

          If you need to output HTML with a snippet, just build a string containing the HTML and return it from the snippet. The returned string will replace the snippet tag.


          $output = "";
          $x = 20
          
          $output .= '<p>This is how many there are: ' . $x . '</p>';
          $output .= '<p>This is another line</p>';
          
          
          return $output;
            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