We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7127
    • 28 Posts
    Hi,

    I’d like to create a site for the school class of my daughter. I want to design two template, one for boys and one the girls. These two designs should be linked to the usergroups boys or girls, is there a chance of getting a snippet or something like that, or a workaround?

    Many thanks
    derluecke
      • 4310
      • 2,310 Posts
      A snippet along these lines in your template should work, untested and may need tweaking wink
      <?php
      $output = '';
      $boys = $modx->isMemberOfWebGroup( array('Boys'));
      if ($boys === true) {
      $output .= 'Your Boys template HTML here...';
      } 
      else {
      $output .= 'Your Girls template HTML here...';
      }
      return $output;
      ?>
        • 7127
        • 28 Posts
        Hm,
        I’ve tried it, but I’not quite sure were to put the snippet call. I inserted it in the templates. First into the body them into the first <div>. It returned the following:
        Parse error: syntax error, unexpected T_VAR in /home/www/ent7a24/html/content/manager/includes/document.parser.class.inc.php(772) : eval()'d code on line 27


        This function:
            function DocumentParser() {
                $this->loadExtension('DBAPI') or die('Could not load DBAPI class.'); // load DBAPI class
                $this->dbConfig= & $this->db->config; // alias for backward compatibility
                $this->jscripts= array ();
                $this->sjscripts= array ();
                $this->loadedjscripts= array ();
                // events
                $this->event= new SystemEvent();
                $this->Event= & $this->event; //alias for backward compatibility
                $this->pluginEvent= array ();
                // set track_errors ini variable
                @ ini_set("track_errors", "1"); // enable error tracking in $php_errormsg
            }


        line 27:
        $this->pluginEvent= array ();


        thanks for your help
        Olaf
          • 7127
          • 28 Posts
          Now, I’ve test several things.
          It works with textstrings, f.e. boys/girls as simple text
          It works with chunks, f.e. a calendar chunk

          But it just inserts divs or text not whole templates. I receive error message like those above.

          olaf
            • 20413
            • 2,877 Posts
            Check http://www.modxcms.com/TemplateSwitcher-565.html
            I remember it could produce links that adds ?template=name

            Maybe that can help if you show the users a different navigation menu.
              @hawproductions | http://mrhaw.com/

              Infograph: MODX Advanced Install in 7 steps:
              http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

              Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
              http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
              • 7127
              • 28 Posts
              Hi,

              yes, it kind of works, could be a beginning, but it’s not as convenient as I hoped it could be. I would prefer a more dynamic way.

              But thank you, i will use now and I’m hoping for the solution via usergroups

              greetings
              Olaf
                • 20413
                • 2,877 Posts
                If you have the plugin installed this might work:
                <a href="[~1~][!Template!]">Home</a>


                Then have your snippet Template:
                <?php
                $output = '';
                $boys = $modx->isMemberOfWebGroup( array('Boys'));
                if ($boys === true) {
                $output .= '|QM|template|EQ|boys';
                } 
                else {
                $output .= '|QM|template|EQ|girls';
                }
                $output .= str_replace("|QM|", "?", $output);
                $output .= str_replace("|EQ|", "=", $output);
                return $output;
                ?>


                Not sure if that’s the way one put the character replacement
                http://modxcms.com/forums/index.php/topic,33101.msg201972.html#msg201972
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                  • 7127
                  • 28 Posts
                  It seems to me, that we found a solution with the german modxcms.de-Team.

                  1. install PHx
                  2. install loadTemplate-Snippet by Bogdan
                  <?
                  $path="assets/templates/";
                  include($path.$name);
                  ?> 

                  3. Load your template.html (s) to assets/templates
                  4. create new template with this call:
                  [+phx:mo=`usergroup`:then=`[[loadTemplate? &name=`template1.html`]]`:else=`[[loadTemplate? &name=`template2.html`]]`+]

                  5. Change your documents to the new created template
                    • 7127
                    • 28 Posts
                    trouble is EasyEvents isn’t working anymore

                    there’s a solution here
                    http://modxcms.com/forums/index.php/topic,33316.msg202687.html#msg202687