Hello,
I have a URL link with a tag= value. However, the value for the tag includes commas, & and whitespaces, therefore the tag value in my URL only shows the first word of my tag value string.
I am using xpdo to interact with my database tables. Here is what my xpdo call look like:
$tag = $_GET["tag"];
foreach ($result as $r){
$resource[] = $modx->getObject('modTemplateVarResource', array (
'tmplvarid' => 8,
'value' => $tag,
'contentid'=> $id,
));
}
In my db table, the value is 'Agencies and Sponsors'. Whereas in my URL, the tag value is "Agencies". Is there a way, using XPDO to query this so that it will match "Agencies" with "Agencies and Sponsors" from the table??
or LIKE %tag%
$tag = $modx->quote($_GET['tag']);
foreach ($result as $r){
$c = $modx->newQuery('modTemplateVarResource');
$c->where(array(
'tmplvarid' => 8,
'contentid' => $id, // I assume you're setting $id somewhere
'value:LIKE' => '%' . $tag . '%',
));
$resource[] = $modx->getObject('modTemplateVarResource', $c);
}
[ed. note: BobRay last edited this post 11 years, 3 months ago.]