-
☆ 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
-
☆ 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)
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’,
),
);
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.
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.
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.