Hi guys, i have some serious problems in getting to know why datagrid widget is acting "funky" when i try to bind a simple .csv file.
Actually I’ve spent some time on the forum and i was carefully reading this post
http://modxcms.com/forums/index.php/topic,1666.0.html about the datagrid widget. Well, lemme tell you that after a lot of tries i still didn’t get it working so i am almost trying to giving up to this mess since it starts making my head ache!
So, here is my situation:
I created a new TV called "products_datagrid" this being a datagrid widget that i want to bind to a simple products.csv file i have into assets/files/products/products.csv
products.csv being a lame .csv file like this:
PRODUCT,DESCRIPTION,PRICE
product1,description1,price1
product2,description2,price2
So, i thaught myself that i just needed to bind the widget to the corresponding .csv by doing in the widget "Default Value" simply @FILE assets/files/products/products.csv
Setting my COLUMN NAMES and FIELD NAMES to be EXACTLY! PRODUCT,DESCRIPTION,NAME
What a surprise when i found that on my products page i got this:
A table with the columns like this:
PRODUCT | DESCRIPTION | NAME
p
r
o
d
u
c
t
1
,
d
e
s
c
r
i
p
t
i
o
n
1
,
p
r
i
c
e
1
So as u see everything is acting weird basically i got the line in my csv as a "column" and the whole widget is displaying just a single field in a messy way?????
So, after reading through some posts in the forum i tryed with the @EVAL and by using the fgetcsv function:see below
@EVAL
$handle = fopen("/server/path/to/file/htdocs/assets/files/board.csv", "r");
$row = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if($row) {
$results[] = $data;
}
$row++;
}
fclose($handle);
return $results;
being in my case the path to the .csv $handle = fopen("/assets/files/products/products.csv", "r");
results is that now i have an "empty record" message.
I am completely stuck and i really do not know what am i doing wrong, i’ve read through all of the posts about the datagrid widget but with no luck, and also, lemme tell that the documentation for the widget itself it’s very poor, so if anybody here can tell me the reason of all this i’d appreciate.
Thanks in advance!