We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20014
    • 200 Posts
    I am trying how figure out how to send a user agent to other content using the trusty if or else statement, the only thing which occurs to me is to use a redirect snippet, have seen a few posts on this subject and have seen the extra Mobile Template Switcher for EVO, but I am on revo and the other solutions are not quite what I am looking for.

    if this riderect here
    else redirect there

    the problem is that I am not sure I can do this, I have seen opengeek’s direction on how to do a redirect
    $modx->sendRedirect($modx->makeUrl($id, '', '', 'full'));


    and I know I can make the snippet and then call it [[redirect?id=`2`]] or something to that effect to send to another container, but I need to place it directly within the larger mobile detect script, can I call a snippet within a snippet like I would a chunk?
      • 19534
      • 183 Posts
      The runSnippet method of the $modx object may be of interest for you.
        Add-On to easily manage your multilingual sites: Babel
        • 20014
        • 200 Posts
        thanks for pointing me in the right direction! so it would be something like this, in the if and else I would place:

        $redirect, [ $params = array ()]


        then I would create a snippet named redirect with parameters for a document with an id of 2 if that was the container with the mobile content like so:
        $params['id'] = '2'; 
        $output=$modx->sendRedirect($modx->makeUrl($id, '', '', 'full'));


        or like this maybe?
        $params['id'] =$modx->resource->('2');
        $output=$modx->sendRedirect($modx->makeUrl($id, '', '', 'full'));



        sorry for my php skills, I have a feeling it’s wrong. Am I getting close?