We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38740
    • 45 Posts
    Hi BobRay,
    I call a snippet, that only contains "echo $modx->context->key;", from a chunk that then only selects the resources of the returned context. If i exchange the "echo $modx->context->key;" in the snippet for you suggestion "$modx->context->get('key');" it doesnt return the context name it seems... i get ALL resources.

    Would like to understand how you meen i should use this and why it is more correct?

    Thx again!

    [[!getResources?
       &context=`[[!sptGetContextName]]`
       &limit=`0` 
       &parents=`0` 
       &sortby=`{"menuindex":"ASC"}`
       &tpl=`chkDisplayFrontBtn`
       &tplFirst=`chkCreatePageSkip`
    ]]
      ____________________________________________________
      • 38740
      • 45 Posts
      Hi BobRay,
      I call the snippet that returns the context name (with my string above) from a chunk to select only the resources of that context. If i place your line ($modx->context->get('key');instead of mine in the snippet i get all resources, seems your line does'nt return the context-name.

      How can this be, or have i miss understood something?

      [[!getResources?
         &context=`[[!sptGetContextName]]`
         &limit=`0` 
         &parents=`0` 
         &sortby=`{"menuindex":"ASC"}`
         &tpl=`chkDisplayFrontBtn`
         &tplFirst=`chkCreatePageSkip`
      ]]
      
        ____________________________________________________
        • 3749
        • 24,544 Posts
        Sorry, I should have written:

        return $modx->context->get('key);




        ---------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using . . .
        MODX info for everyone: http://bobsguides.com/modx.html


          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
          • 38740
          • 45 Posts
          Yea, that works better, thx BobRay (have your book here, great stuff! (i should read it some day ;-)
            ____________________________________________________
            • 43732
            • 9 Posts
            Quote from: ottogal at Mar 26, 2012, 10:36 PM
            Hi johnjohn22,

            you could try the following steps:

            (I assume that www.domain.com/ is the root of your main MODX installation, and you have a published start page "Home" in it.)

            (1)
            Install ContextRouter via the Package Management.

            (2)
            On the server, using some FTP Client, create a subdirectory /dev/ below the root directory.

            (3)
            Copy the files index.php and config.core.php from the root directory to this subdirectory /dev/.

            (4)
            Modify the file /dev/index.php in the following way:
            Near the end of the file you find the lines
            /* Initialize the default 'web' context */
            $modx->initialize('web');
            
            Replace them by
            /* Initialize the 'dev' context */
            $modx->initialize('dev');
            

            (5)
            In the file /dev/config.core.php, replace the line
            define('MODX_CORE_PATH', dirname(__FILE__) . '/core/');
            
            by the line
            define('MODX_CORE_PATH', dirname(dirname(__FILE__)) . '/core/');
            
            (Because from the subdirectory's "dev" point of view the core is to be found one level higher.)

            (6)
            In the MODX Manager, create the Context 'dev'.
            Create a resource "Dev-Home" under this context and publish it.

            (7)
            Go to the Context Settings panel of the Context 'dev' and create these settings:
            key: site_url  -> value: http:/ /www.domain.com/dev/   (omit the blank between / /)
            key: base_url  -> value: /
            key: http_host -> value: www.domain.com/dev
            key: site_start -> value: ##  (= the ID of the start page "Dev-Home" in the context 'dev')
            

            (8 )
            Change to the Context 'web', go to its Context Settings panel and create these settings:
            key: site_url  -> value: http:/ /www.domain.com/   (omit the blank between / /)
            key: base_url  -> value: /
            key: http_host -> value: www.domain.com
            key: site_start -> value: ##  (= the ID of the start page "Home" in the context 'web')
            


            That should do it.
            When you now (after a refresh of the cache) launch the URL www.domain.com/ you should see the page "Home", and when you launch the URL www.domain.com/dev/ you should see the page "Home-Dev". (Hope I'm right...)

            Good luck!




            I followed this steps but im having some problems with images path. When i choose a imagen from my directory it ok but when i show it in the web there is a path problem.
            When i inspect my image i have this
            <img src="movil/imagesMovil/slider-brazil.png" width="275" height="180" alt="Rio de Janeiro Prom" title="Rio de Janeiro Prom">

            why its adding movil/ i dont understand that, please help meee !
            • @adanyc if you did this I suggest you undo it and just use my context router method and your issues will be fixed, when you use Context Router you don't need to do anything besides creating Context Settings so steps 1-6 are not needed.

              This might be why you are having issues.
                Benjamin Marte
                Interactive Media Developer
                Follow Me on Twitter | Visit my site | Learn MODX