We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19980 ☆ A M B ☆
    • 275 Posts
    Hi
    i am calling :
    $modx->runSnippet(’getPage’,$parameters)

    with :
    $parameters = array(
    ’elementClass’ => ’modSnippet’,
    ’element’ => ’getResources’,
    ’pageVarKey’ => ’page’,
    ’limit’ => ’5’,
    ’tpl’ => ’listing’,

    ’parents’ => $parent,
    ’resources’ => "$idsToSearch",
    ’sortby’ => ’editedon,createdon’,
    ’includeTVs’ => ’1’,
    ’processTVs’ => ’1’,
    ’tvFilters’ => ’hidemenu==0’,
    ’where’=> ’{"template:=":128}’,
    ’showHidden’=> 0,
    ’cache’ => 0,
    ’tvPrefix’=> ’’,
    ’sortbyTV’=> ’premium’, ’sortdirTV’ => ’ASC’,
    );
    Some parameters do not work , like :
    ’tvFilters’
    ’where’
    ’showHidden’

    I seem to realise that ’tvFilters’ => ’hidemenu==0’, is not good but other parameters should help me but actually not.

    I mean i get docs that are actually hidden from menu (hidden=1), and template = any number not only 128.

    Any suggestion is very welcome, thank you
      modx and ecommerce pro
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      hidemenu is not a template variable, it’s a resource field. It should go into the where clause instead...

      Are you sure sortby supports multiple items? (I’ve not checked this, but the docs don’t mention it specifically)
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 3749
        • 24,544 Posts
        The where member can be an array rather than a JSON string. I prefer to do it like this with simple criteria because is simplifies the syntax and I make fewer mistakes:

        <?php
        'where' => array(
                'published' =>'1',
                'hidemenu' =>'0',
                'template' => '128',
        );


        [Edit] Oops. It needs to be a JSON string. What I meant was that I usually do it like this:

        ’where’ => $modx-toJSON(
        array(
        ’published’ =>’1’,
        ’hidemenu’ =>’0’,
        ’template’ => ’128’,
        ),
        );
          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
          • 19980 ☆ A M B ☆
          • 275 Posts
          Hi, thanks for replies.
          ok, i try to set the parameters to :

          			$where = $modx->toJSON(
          			    array(
          				'published' => '0',
          				'hidemenu' => '0',
          			    )
          			); #echo $where;
          			$parameters = array(
          				'elementClass' => 'modSnippet',
          				'element' => 'getResources',
          				'pageVarKey' => 'page',
          				'limit' => '5',
          				'tpl' => 'list',
          				'parents' => $parent,
          				'resources' => "$idsToSearch",
          				'sortby' => 'editedon',
          				'includeTVs' => '1', 
          				'processTVs' => '1',
          				//'tvFilters' => 'hidemenu==0',
          				'where'=> $where,
          				//'showHidden'=> 0,
          				'cache' => '0',
          				'tvPrefix'=> '',
          				'sortbyTV'=> 'premium', 'sortdirTV' => 'ASC', 
          			);


          & then I am calling getPage (not getResources directly) with
          $modx->runSnippet('getPage',$parameters)


          & still have the same output... is it weird or i am just not seeing anything? Thank you
            modx and ecommerce pro
            • 3749
            • 24,544 Posts
            In theory, the parameters you’re sending to getPage should be passed through to getResources, but I’ve never tried it.

            What happens if you just do runSnippet(’getResources’, $parameters); ?

            I would first try doing everything in the front end with just getResources, then add get page.

            Then, try just getResources in your code, before adding getPage.


            BTW, are you sure you need a snippet? So far, I think everything in your code can be done in the front end.



              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
              • 19980 ☆ A M B ☆
              • 275 Posts
              Thank you very much indeed for your reply cool.
              The reason I used getPage is because I need the pagination.

              >>Then, try just getResources in your code, before adding getPage.
              getResources worked as it was required : did not display hidden docs.

              But the getPage seems to ignore this extra parameter. Just wanted to check it is true not only for my website.. Probably modx team will notice this as well embarrassed
                modx and ecommerce pro
                • 3749
                • 24,544 Posts
                That’s very strange. The default property for &showHidden is set to "no" in the getResources properties, unless you’ve changed it. Even if the property you set is not getting through, it still shouldn’t show them.
                  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
                  • 19980 ☆ A M B ☆
                  • 275 Posts
                  Quote from: BobRay at Feb 22, 2011, 12:24 AM

                  That’s very strange. The default property for &showHidden is set to "no" in the getResources properties, unless you’ve changed it. Even if the property you set is not getting through, it still shouldn’t show them.

                  you’re reight Bob

                  the docs were all set hidden = 0, then the script updated some of them to be hidden = 1. But still all resources come up >:(
                  We clean the cashe but it didn’t help, i was thinking only changing this value hidemenu to 1 from 0 would do the trick ... pearhaps i am to update any other parameter of the doc which is t be hidden?

                  Thank you
                    modx and ecommerce pro
                    • 3749
                    • 24,544 Posts
                    Sorry, I’m not sure what you’re saying. Do you mean that the Hide From Menus checkbox was set on the resources and that it was changed after you ran the snippet?

                    If the Hide from Menus checkbox of the resource is checked and that parameter is at it’s default value on the properties page getResources, those pages should be skipped if you don’t send that parameter.

                    One thing more you could try is to add a &showHidden property to the getPage snippet’s default properties and set it to ’No’. Then leave that parameter out of any snippet tags.
                      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
                      • 19980 ☆ A M B ☆
                      • 275 Posts
                      If you look at my snippet call you will see ’resources’ => "$idsToSearch",
                      where $idsToSearch is dynamic and has more priority then &where parameter as it proved to be.

                      So after I disabled //’resources’ => "$idsToSearch",
                      the snippet works fine.

                      Hope it will be usefull for you as well, please note this wink

                      Thank you for keeping on with this.
                        modx and ecommerce pro