We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21341
    • 26 Posts
    Hello,
    i have problems getting the SMF forum in place. The Gallery 2 Module works fine, but the SMF forum kills the layout after clicking a link, because it calls itself and overrides modx.

    Therefore and for other ideas i want to find out a way to include template parts in other templates like SMF forum. Besides the usermanagement i can include everthing in modx by editing the included softwares template.

    I searched the forum and all i find were solutions on how to edit the template within modx with variables, placeholders etc., but found no way to include the template via a php call from other sites.

    Can you help me?

    Btw: i use wayfinder, a way to include directly the menu would satisfy me.
      • 21191
      • 236 Posts
      here is an idea...

      make pages and uncheck "display in menu" or hide them someplace.
      make a page and call it "header" use a blank template for it.. and only insert the wayfinder call.

      it should spit out raw html code. then do a "include" in the php to call it in as any other file.

      d likewise with the others

      I have not tested this, it’s just an idea
        ~Shawn Himmelberger
        Check out my MODx Development and MODx Design Company - Himmelberger Design
        • 21341
        • 26 Posts
        Havent tried it yet, but it should work if php accepts arguments in the URL of the include call.

        Thanks!

        My first thought was to analyze the wayfinder file and see if its could work alone or has to be included in modx system, but i ll give your idea a shot, because its easier. wink

        EDIT:
        The method doesnt work. I tried include with $_GET, eval, passthru etc., but i dont get the wayfinder menu over a non modx site.
        The basic question is how to execute php code over an URL with parameters and get the output? MODx should work in the background, build the site and return it.
        And after getting the site, the unnecessary HTML must be outsorted.
          • 21191
          • 236 Posts
          well all we are trying to do is get the raw html output inserted into another page right?

          I remember back in the day when I did php includes and not MODx, I could do a include("http://yahoo.com");
          and it would insert the whole page inside my site.

          so that was my idea.. use that same concept.. and just make pages in the modx system that only output those sections you need.

          Now if you want to use the wayfinder features that expands the document tree based on the document that you are at, I double that would work. At least not with any help from me smiley
            ~Shawn Himmelberger
            Check out my MODx Development and MODx Design Company - Himmelberger Design
            • 4041
            • 788 Posts
            I think the easiest solution is to create a custom php file that queries the modx database and replicates the menu code as much as possible...

            I am not familiar with the wayfinder structure, but basic php can do the same thing I’m sure and then include it wherever you need... the smf is a tricky bugger to tie into undecided
              xforum
              http://frsbuilders.net (under construction) forum for evolution
              • 21341
              • 26 Posts
              If you are fit in such things, i posted a thread where you can help me: Call wayfinder from another non modx site - include the menu in other templates smiley

              Because of getting no ID by modx the menu dont have to change while surfing the forum/embedded page, and therefore i could copy the HTML code into another template, but then i have to change it everytime i add a menu item. I want to understand modx and use it well, integrating by faking rather than integrating is not my thing.

                • 14050
                • 788 Posts
                The easiest way that I can think of to have Wayfinder work in your other site is to make the following hack to the Wayfinder code.

                assets/snippets/wayfinder/wayfinder.inc.php

                Right the "run()" function around line 46, change:

                		ksort($this->docs);
                		
                		$output = $this->buildMenu();
                		return $output;


                To this:

                		ksort($this->docs);
                		
                		$output = $this->buildMenu();
                		$this->writeToFile($modx->config['base_path'] . 'assets/snippets/wayfinder/output.txt',$output);
                		return $output;


                Then right before the last closing bracket at this function:

                	function writeToFile ($wxUpdateFile, $wxWrittenInfo) {
                
                		// Let's make sure the file exists and is writable first.
                		if (is_writable($wxUpdateFile)) {
                
                		   if (!$handle = fopen($wxUpdateFile, 'w')) {
                		         exit;
                		   }
                
                		   // Write content to our opened file.
                		   if (fwrite($handle, $wxWrittenInfo) === FALSE) {
                		       exit;
                		   }   
                		   fclose($handle);
                		}
                		return;
                	}


                Next you need to create a text file in assets/snippets/wayfinder called output.txt and CHMOD it to 666.

                That will give you the menu code in a text file. All you need to do now is do an include(URL_TO_OUTPUT.TXT) in your php file and it will have the same code as your menu on MODx.

                Of course this will add a little overhead to the Wayfinder script, and you might want to make this a parameter to Wayfinder.
                  Jesse R.
                  Consider trying something new and extraordinary.
                  Illinois Wine

                  Have you considered donating to MODx lately?
                  Donate now. Every contribution helps.
                  • 21341
                  • 26 Posts
                  Nice modification, jesster444, thanks!

                  This way causes a lot of perfomance everytime someone clicks the menu. The file will be rewritten by all surfers and changes in weired behavior for the one surfer on the integrated site like SMF.

                  I use one database for all the content and i allready postetd the thread and i think i go for calling the db and use the wayfinder.inc.php code. The connection is made by SMF, and therefore my aim are the functions of wayfinder.

                  Any experiences?
                    • 33337
                    • 3,975 Posts
                    Did u check this: http://wiki.modxcms.com/index.php/MODx_site_menu_in_external_PHP_app ??

                    Hope it helps.

                    regards.
                      Zaigham R - MODX Professional | Skype | Email | Twitter

                      Digging the interwebs for #MODX gems and bringing it to you. modx.link
                      • 21341
                      • 26 Posts
                      Thanks for poiting me!

                      I didnt know about a API, everytime interesting working with modx wink

                      This code works, but i have to include some style. And now i can include the ajaxsearch too smiley
                      <?php
                       
                      $path = './';
                      include_once($path.'modxapi.php');
                       
                      $modx = new MODxAPI();
                      // connect to db and load settings
                      $modx->connect();
                      $modx->getSettings();
                      
                      $html= $modx->runSnippet('Wayfinder', array('startId' => '0', 'level'=>'2', 'hideSubMenus'=>'true'));
                      echo $html;
                       
                      ?>