We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8168
    • 1,118 Posts
    Thanks modx.customize

    I see what you mean about the on page Render issue....

    I don’t need any additional detection to occur - the detection as per the Mobile Template Switcher is great, it works out if a mobile is being used to view the page or a desktop and serves up a corresponding relevant template in accordance with that discovery - there is also a feature which allows the user to override this if they so wish, so they could view the mobile version on a desktop and vice-versa. This current functionality is great and works really well.

    The enhancement we are looking for is to allow a MODx editor to specifiy a specific mobile template that the page should be rendered in IF the detection script serves up the page in it’s mobile view. Currently the plugin forces all pages to be rendered in the SAME mobile template - you can not specifiy on a page-by-page basis which template you want the page to use IF the current plugin renders the page as a mobile view.

    We were hoping to achieve this by adding a TemplateVariable to the pages of the site in which the MODx editor could specify the template to use IF the page is served as a mobile version. This would then mean that the site when served on a mobile could use multiple templates just like the normal desktop version.

    So in essence we are looking at creating a 2nd version of the "Uses Template" dropdown option on the page edit section - but this time specifying which template the page should use IF it is rendered in the mobile version (i.e. when viewed on a mobile or when the user has set the plugin to force the site to be rendered in its mobile version)


    Hope that makes sense! (so no need for "pageA-DesktopTemplate", "pageA-iphoneTemplate", "pageA-NokiaTemplate", "pageA-OperaTemplate", "pageB-DestopTemplate", "pageB-iphoneTemplate", "pageB-NokiaTemplate", "pageB-OperaTemplate" etc, all we need is "pageA-DesktopTemplate", "pageA-mobileTemplate", "pageB-DesktopTemplate", "pageB-MobileTemplate")


    Cheers dubbs.
      • 20413
      • 2,877 Posts
      Are we talking about the same plugin?¿
      This plugin combines browser detection and a URL-parameter override to
      show/hide portions of any template delineated by <mobile> and <standard> tags.

      How are you using this plugin right now?
      "browser=mobile" will cause all portions of the template wrapped with <standard>
      tags to be deleted.
      "browser=standard" will cause all <mobile> nodes to be deleted.
        @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
        • 8168
        • 1,118 Posts
        Yep using that plugin - but not using the hide/show content feature.

        Currently have my ’desktop’ site setup to render all pages in the page Template that is relevant as per the "Uses template" option. Then ALL the pages when viewed on a Mobile use a template called "Mobile" - this is hard-coded in the configuration section of the Plugin when you go to edit the Mobile Template Switcher plugin. You have an option to hard-code the template that the pages will be rendered in if the site is accessed by a mobile device.

        It is this hard-coding I am looking to amend to get it to work in a more dynamic / intelligent way to allow the MODx editor to set a mobile-template for the page to rendered in when its viewed on a mobile device.
          • 8168
          • 1,118 Posts
          P.S. Just to be sure we are all talking about the same plugin it’s this one here - http://modxcms.com/extras/package/591
            • 4041
            • 788 Posts
            Here’s a possible solution (untested as of yet) - create a snippet named "get_mobile_template" with the code below. See notes for usage smiley

            <?php
            /*    get_mobile_template
            
              usage:
              
              <mobile>[!get_mobile_template!]</mobile>
              <standard>{{my_standard_template}}</standard>
            
              Ex:
              If there is a TV named "MobileTemplate" associated with the document and has a value set,
              a Chunk with the same name is output, otherwise the $MobileTemplateDefault chunk is used.
            
            */
            
            // set the name of the Chunk for the overall default mobile template
            // this example looks for a chunk named "Def_Mobile_tpl"
            $MobileTemplateDefault ='Def_Mobile_tpl';
            
            // name of the TV which would set the value of the mobile template
            $MobileTemplateTVname ='MobileTemplate';
            
            
            $thisid = $modx->documentIdentifier;
            $output ='';
            
            // check to see if the mobile template TV has a value set
            $tvcontent = $modx->getTemplateVarOutput(array($MobileTemplateTVname), $docid=$thisid);
            
            // figure out which Chunk nmae we are going to use as the template
            $tpl = $tvcontent[$MobileTemplateTVname] !='' ?  $tvcontent[$MobileTemplateTVname] : $MobileTemplateDefault;
            
            // output the chunk
            $output .='{{'.$tpl.'}}';
            
            return $output;
            ?>
              xforum
              http://frsbuilders.net (under construction) forum for evolution
              • 20413
              • 2,877 Posts
              Ok, I installed it! smiley

              1. Function eregi() is deprecated as of PHP 5.3.0
              so replaced it with stristr()

              2. Then I have to(!) use the _tags_ in my template
              <mobile>
              mobil template
              </mobile>
              <standard>
              standard template
              </standard>


              The node id’s are only the names; the $_GET / URL params.

              3. I now update my template to this
              <mobile>
              [!template?option=`[*TemplateOption*]`!]
              </mobile>
              <standard>
              standard template
              </standard>

              + Install my first snippet (make sure no space after <<<TPL ) above and create a text tv: "TemplateOptions" and assign it.

              4. This works fine! smiley

              5. Removing snippet creating 3 chunks:
              {{iphone01}} {{iphone02}} {{default}}

              6. Changing the TV
              input options:
              {{iphone01}}||{{iphone02}}||{{default}}

              Default option: {{default}}
              Type: DropDown List Menu.
              and in template only ...<mobile>[*TemplateOption*]</mobile>

              7. Client are now being able to change template per resource, for those resources
              the plugin have detected to be mobile.

              // I can’t see how this plugin would work for you, if you DON’T use the tags in you MODx template...
              Coding this into the Plugin is possible. But no additional code is needed!!
              ONE single TV is all you need. Then this one TV can use chunks, files or even other resources
              as templates... //turn off cookie usage when testing.
                @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
                • 8168
                • 1,118 Posts
                Breezer and Mr Hall! These both work well! Thanks so much for helping out here! It seems I had v1.3 of the Mobile Template Switcher and that was not using the <mobile>Blah</mobile> or <standard>Blah</standard> tags at all hence the confusion.... My bad!

                Thanks again guys!
                  • 20413
                  • 2,877 Posts
                  Donate to MODx.
                    @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