tulavu
October 4, 2020, 1:05pm
1
Hi,
I have installed and set up the “Doodles” package.
doodles.schema.mysql.xml:
<?xml version="1.0" encoding="UTF-8"?>
<model package="doodles" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM">
<object class="Doodle" table="wordsENG" extends="xPDOSimpleObject">
...
I have run the script build.schema.php and now the table modx_wordsENG
is properly created, I also entered some dummy data inside of it.
My question is: what would be the best solution to retrieve these data and to display them into my modx resource.
I tried to use pdoResources, but it does not display nothing:
[[!pdoResources?
&loadModels=`wordsENG`
&class=`Doodle`
&tpl=`@INLINE <p>{{+id}} - {{+myfield}}</p>`
&showLog=`1`
]]
I have attempted different settings for pdoResources and it displays just nothing, even the &showLog does not output nothing. I have also tried the other snippets of pdoTools but without success as of today.
Thank you for the help !
I believe the &loadModels
-property has to be the name of your package.
[[!pdoResources?
&loadModels=`doodles`
&class=`Doodle`
&tpl=`@INLINE <p>{{+id}} - {{+myfield}}</p>`
&showLog=`1`
]]
tulavu
October 4, 2020, 2:17pm
3
Thank you @halftrainedharry , I already tried this and it didn’t help, I’m still trying to figure out what the problem is
If you put this code in a snippet an run it, do you see any output?
<?php
$base_path = $modx->getOption('core_path').'components/doodles/';
$modx->addPackage('doodles', $base_path.'model/');
$output = array();
$result= $modx->getCollection('Doodle');
foreach($result as $res){
$output[] = $res->toArray();
}
return $modx->toJson($output);
1 Like
tulavu
October 4, 2020, 3:35pm
5
Oh this is great yes I can see the output !
I’m going to try to find out why the pdoResource snippet is not working but still your answer helps me a lot Thanks again @halftrainedharry !
Have you check the error log? Maybe “pdoResource” puts something in there.
1 Like
tulavu
October 4, 2020, 3:48pm
7
Yes i was just at the moment having a look at it and you are right:
[pdoTools] Error 42S22: Unknown column ‘publishedon’ in ‘order clause’
I’ll sort this out and update this post when I found the solution
tulavu
October 4, 2020, 3:52pm
8
I just added this to my snippet call and now it works fine :
&sortby=`id`
&sortdir=`asc`
Thank you for the help !
1 Like
migxLoopCollection would also work
[[!migxLoopCollection?
&packageName=`doodles`
&classname=`Doodle`
&tpl=`@CODE:<p>{{+id}} - {{+myfield}}</p>`
]]
1 Like
tulavu
October 5, 2020, 3:10pm
10
Good to know, thank you @bruno17
system
Closed
October 7, 2020, 3:10pm
11
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.