-
- 57 Posts
Hey,
I’m using the getResources snippet in modx revlution (2.0-pl) and i want to get all resources with a spevial tv value of
all contexts.
so i’am calling:
$output = $modx->runSnippet('getResources',array(
'parents' => '0',
'limit' => '20',
'tvFilters' => $field.'=='.$current_internationalkey //'tvFilters' => 'internationalkey==ueber_uns'
));
return $output;
But I’m only getting the ressource of the same context, where the snippet is placed.
Has anybody an idea what i can do?
christian seel - www.christianseel.com
web developer & designer at chsmedien.de
twitter: @christianseel / @chsmedien
-
- 5,888 Posts
there is a parameter &context, which you can try to set.
Or you can try to hack getresources a little like that:
/* build query */
$carray=array(
'deleted' => '0'
,'published' => '1'
,"`modResource`.`parent` IN (" . implode(',', $parents) . ")"
);
if ($context <>'all'){
$contextResourceTbl = $modx->getTableName('modContextResource');
$context = empty($context) ? $modx->quote($modx->context->get('key')) : $modx->quote($context);
$carray[] = "(`modResource`.`context_key` = {$context} OR EXISTS(SELECT 1 FROM {$contextResourceTbl} `ctx` WHERE `ctx`.`resource` = `modResource`.`id` AND `ctx`.`context_key` = {$context}))";
}
$criteria = $modx->newQuery('modResource',$carray);
if (empty($showHidden)) {
$criteria->andCondition(array('hidemenu' => '0'));
}
and use &context=`all`. Did not test it, but perhaps this can do what you want.
-
- 57 Posts
Great! I forgot to lock inside the code...thanks for the hint.
I have another little problem now with getResources:
when I generate a link to a ressource inside the default web-context (1st context with my main domain) from anothercontext (2nd context with subdomain), the base_url(?) of the link is wrong.
example:
generates in my 2nd context (subdomain) with an ID of my 1st context (main domain) this link:
http://mysubdomain.domain.com/jobs.html (wrong)
it should be
http://www.domain.com/jobs.html
In the other direction the links are correct.
christian seel - www.christianseel.com
web developer & designer at chsmedien.de
twitter: @christianseel / @chsmedien
-
- 4,149 Posts
try [[~[[+id]]? &scheme=`full`]] and see if that works; might not.
shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect |
github |
splittingred.com
-
- 57 Posts
does not work! only adds the full absolute path to the link of the same context...
christian seel - www.christianseel.com
web developer & designer at chsmedien.de
twitter: @christianseel / @chsmedien
Sounds like you do not have your site_url or base_url properly configured in your subdomain context.
-
- 57 Posts
Well, I got it.
But it was not a missing setting in my subdomain context. The solution was to set the site_url in the web-context settings.
I thought modx will get this setting from the global settings...
Thanks for your help!
christian seel - www.christianseel.com
web developer & designer at chsmedien.de
twitter: @christianseel / @chsmedien
-
- 57 Posts
One more thing:
I’m searching for a way to get the context-description for each of the documents from the getResources snippet as placeholder for my tpl. Has someone a hint?
christian seel - www.christianseel.com
web developer & designer at chsmedien.de
twitter: @christianseel / @chsmedien
-
- 57 Posts
Great! Thanks for your support jason!
christian seel - www.christianseel.com
web developer & designer at chsmedien.de
twitter: @christianseel / @chsmedien