I am new to ModX revolution, and can't figure it out. I need to show pages with parent from url (e.g. clinic=21) and if no clinic set then set parents to a list. I've got this:
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&parents=[[!If? `[[!searchFieldClinic? &field=`clinic`]]`=`` &then=`127,106` &else=`[[!searchFieldClinic? &field=`clinic`]]`]]
]]
but the if always returns 127,106,70,76,83,93,92,99,113,120,134,148,155,162,169,176,704,975,183
What am I doing wrong?
Thanks in advance
Figured out myself, thanks :)
[[!getPage?
&elementClass=`modSnippet`
&element=`getResources`
&parents=[[!If?
&subject=`[[!searchFieldClinic? &field=`clinic`]]`
&operator=`EQ`
&operand=``
&then=`127,106,70,76,83,93,92,99,113,120,134,148,155,162,169,176,704,975,183`
&else=`[[!searchFieldClinic? &field=`clinic`]]`
]]
]]
Related
I recently started working with logic apps.
I got stuck with a simple array filter.
How do I get to fix the following?:
#and(equals(item()?['ReportName']?['Value'], body('Get_response_details')?['rb6faae7228c4454d91422175db06cfde']), and(equals(item()?['Environment']?['Value'],body('Get_response_details')?['r35825e12ace649ec964d24a86d851762']), or(equals(item()?['Role']?['Value'],body('Get_response_details')?['rc456e0fddc9440a09a67cbf979173354'])), equals(item()?['Role']?['Value'], 'AppViewer')))
I want to have a filter that filters when Report name = rb6faae7228c4454d91422175db06cfde,
when Environment = r35825e12ace649ec964d24a86d851762,
AND when Role equals both rc456e0fddc9440a09a67cbf979173354 or 'Appviewer'
( this should return both roles )
That last one I'm struggling with.
Cheers,
Robin
Your brackets seem to be in the wrong place. Can you try this?
#and(equals(item()?['ReportName']?['Value'], body('Get_response_details')?['rb6faae7228c4454d91422175db06cfde']), and(equals(item()?['Environment']?['Value'],body('Get_response_details')?['r35825e12ace649ec964d24a86d851762']), or(equals(item()?['Role']?['Value'],body('Get_response_details')?['rc456e0fddc9440a09a67cbf979173354']), equals(item()?['Role']?['Value'], 'AppViewer'))))
Can anyone please tell me how to put customer's first and last name into the header in OpenCart 2.0?
I am already using this code for OpenCart 1.5.6:
<?php echo $this->customer->getFirstName(); ?>
<?php echo $this->customer->getLastName(); ?>
But this code is not working for OC 2.0
I am getting this error : Undefined property: Loader::$customer in header.tpl
Please help me anyone.
To fix this error you need to call them in the controller instead of in the template.
In catalog/controller/common/header.php add the following code inside the index() function:
$data['customer_firstname'] = $this->customer->getFirstName();
$data['customer_lastname'] = $this->customer->getLastName();
In catalog/view/theme/your-theme/template/common/header.tpl you can echo the first and last name:
echo $customer_firstname;
echo $customer_lastname;
Note that it is better not to edit Opencart core files. Instead you can use VQMod to implement the changes in the header controller.
Hey I had a solution to add first name last name of logged in user :
1.Go To: catalog/controller/common/header.php
Then find public function index () {....
Then add the following code:
if ($this->customer->isLogged()) {
$data['welcome_message'] = sprintf("Welcome %s %s, Enjoy your stay!", $this->customer->getFirstName(), $this->customer->getLastName());
}
Now go to : catalog/view/theme/YOURTHEME/template/common/header.tpl
then put this where you want :
I want to use getResources to get the content from a document, and its child documents. I believe I can used &depth to do this but I cannot seem to get it working.
I have tried 2 approaches:
echo "[[!getResources? $parents=`15` &includeTVs=`1` &resources=`" . $resid . "` &depth=`1` &tpl=`tendertmp`]]";
and:
echo "[[!getResources? $parents=`" . $resid . "` &depth=`1` &includeTVs=`1` &tpl=`tendertmp`]]";
$resid is just a number generated by a snippet - the first example works fine without depth.
Would anyone know the correct way of using depth or a way to get the reources content along with its child resources content?
Why you do not use http://rtfm.modx.com/display/revolution20/modX.runSnippet ?
$output = $modx->runSnippet('getResources',array(
'parents' => $resid,
'depth' => '1',
'includeTVs' => '1',
'tpl' => 'tendertmp'
));
echo $output;
and your second mistake in $parents instead &parents.
I actually do not understand why you are attempting to run getResources from within a PHP Snippet. There is very little reason to do so.
You could simple do a $modx->getCollection('modResource, $someCriteriaHere); or
Call getResources directly from your pages:
[[!getResources?parents=`15`&includeTVs=`1`&depth=`1`&tpl=`tendertmp`]]
I am trying to achieve a very simple goal, however it does not seem to be working. I wish to use Kohana's ORM and conditionally add certain parameters.
For instance:
$query = ORM::factory('user')
->where('foo', '=', 'bar');
if (isset($some_var))
$query->where('field', '=', $some_var);
$query->find_all();
One would think this should work, but all I get from $query is a big fat nothing. Any suggestions I would greatly appreciate! Thanks.
EDIT:
The simple example on this Kohana page even shows a similar query:
http://kohanaframework.org/3.1/guide/orm/examples/simple
...But even when I create a 'user' model instance and then try to find_all() in a separate statement, I get nothing.
This works:
$query = ORM::factory('user')->find_all();
This doesn't work:
$query = ORM::factory('user');
$query->find_all();
Possible bug??
In your example that works, you are assigning the value returned from find_all() to $query. While in the example that is not working, you are not assigning the value returned by find_all() at all.
kohana framework
$query = ORM::factory('user');
$result = $query->find_all();
// you may now loop over $result
When you look over the api, you will see that find() and find_all() work differently.
Your code is perfectly fine, as ORM::where method returns ORM object, so there is no problem with method chaining. You should look for the errors in other place (perhaps your $some_var is set but may be empty, therefore your condition may look different then expected). I'd try with this small change:
if (!empty($some_var))
$query->where('field', '=', $some_var);
Maybe something really simple, I got really big problem with... ORM result.
I'm loading object with relation using with(). It generates following query:
SELECT `article`.`id` AS `article:id`, `article`.`name` AS `article:name`
Now's my question... how to display article name in the view? Sorry for dumb question, I really can't beliebe I'm asking it.
Edit
Here's my code:
$activity = $user->activity->with('article')->where('article.status', '=', 1)->find_all()->as_array();
Relations are correct for sure. I can swear I saw something similar today morning on the Kohana Forums however cannot find it.
Cheers!
I haven't tested it but does it work if you do this:
$activities = $user->activity->with('article')->where('article.status', '=', 1)->find_all();
foreach($activities as $activity) {
echo $activity->name.'<br />';
}