Hi,
I have an about us page for my site. I have the data stored in a table named tblabout.
I need to display this information in a modx page. So I created a snippet as follows
<?php
$output = '';//create variable for holding the output
$sql = $modx->db->query( 'SELECT * FROM `tblabout` LIMIT 0, 1000');//define the DB query, in this case the table is named 'tblabout', add WHERE AND etc. as needed
$resultArray = $modx->db->makeArray( $sql );//put it into an array
foreach($resultArray as $item) //go through each record in the array
{//start looping through the data array
$params['name']=$item['names'];//set the placeholders, the $params sets the name of the placeholder, the $item is the field name from the DB table
$params['about']=$item['content'];
$output.=$modx->parseChunk('about', $params, '[+', '+]');//define the chunk name and process the content
}//finish looping through the data array
return $output;//now return the output from the processed chunk
?>
and a chunk
<h3>[+names+]</h3>
<p>[+content+]</p>
But I cannot get the information to display....
I am trying to call the chunk as follows
I am using Version 1.0.0 on a wamp server.
The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.
-Albert Einstein (1879 - 1955)
Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
-
MODX Staff
- 10,725 Posts
Try $modx->db->getRow() instead of $modx->db->makeArray(). I don’t think makeArray() is what you wanted.
Opengeek:
I just copied the snippit from
http://wiki.modxcms.com/index.php/DB_query_and_Placeholders
I will definitely give your suggestion a try....
or
The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.
-Albert Einstein (1879 - 1955)
Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Well thanks for the update....
Though there is some helpful code there, the wiki at wiki.modxcms.com is 100% user contributed and maintained, so it’s not always reviewed for accuracy or full of official solutions.
Any other ideas on why it doesn’t show anything on my about page....
Can I calling the chunk correctly? Do I need to call the snippet before calling the chunk?
The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.
-Albert Einstein (1879 - 1955)
Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
My snippet name is About.... so when I enter
[!About!]
my page displays
[[About]]
The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.
-Albert Einstein (1879 - 1955)
Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.
-Albert Einstein (1879 - 1955)
Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Thanks I will look into this.
The important thing is not to stop questioning. Curiosity has its own reason for existing. One cannot help but be in awe when he contemplates the mysteries of eternity, of life, of the marvelous structure of reality. It is enough if one tries merely to comprehend a little of this mystery every day. Never lose a holy curiosity.
-Albert Einstein (1879 - 1955)
Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 DAV/2 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635