But you need a MySQL-Database and you need know how to setup the tables (SQL-File is here)...
This is a "ultra alpha unstable"-Version or 0.0.0.1 so if there are any errors, post them here or just delete the script.
- 1. create the database
- 2. create the tables, use this sql-code:
Code: Select all
CREATE TABLE `content` ( `id` int(10) unsigned NOT NULL auto_increment, `content` text NOT NULL, PRIMARY KEY (`id`) ) TYPE=MyISAM AUTO_INCREMENT=1 ; CREATE TABLE `pro_con_assoc` ( `ean` bigint(20) unsigned NOT NULL default '0', `content_id` int(10) unsigned NOT NULL default '0', UNIQUE KEY `ean` (`ean`) ) TYPE=MyISAM; CREATE TABLE `product` ( `ean` bigint(20) unsigned NOT NULL default '0', `name` varchar(255) NOT NULL default '', PRIMARY KEY (`ean`) ) TYPE=MyISAM;
- 3. create a "content.php" file in your "root"-Folder and insert this code:
Code: Select all
<?php $amount = count($this->app[debug][amazon_data][0][Items][Item]); // "ean" is the identifier for the product $ean = $this->app[debug][amazon_data][0][Items][Item][0][ItemAttributes][EAN]; // the name of the product, it is trimmed to 251 characters (the database col can take 255 max) //$name = substr($this->app[debug][amazon_data][0][Items][Item][0][ItemAttributes][Title], 0, 250); $name = $this->app[debug][amazon_data][0][Items][Item][0][ItemAttributes][Title]; // MySQL-Connection $link = mysql_connect("your-hoster.de", "db-username", "db-password") or die("connection error"); mysql_select_db("db-name") or die("database dont exist"); // Query and result $query = "SELECT ean, name FROM product WHERE ean = '".$ean."'"; $result = mysql_query($query) or die ("query-error"); if(mysql_num_rows($result) > 0) { // output while ($row = mysql_fetch_assoc($result)) { //check if item page if($amount == 1) { // check if content is available $get_content = "SELECT product.name AS name, content.content AS content FROM content, product, pro_con_assoc WHERE product.ean = '".$row[ean]."' AND pro_con_assoc.ean = '".$row[ean]."' AND pro_con_assoc.content_id = content.id"; $result_content = mysql_query($get_content); while ($content_row = mysql_fetch_assoc($result_content)) { echo '<h1>'.$content_row[name].'</h1>'; echo $content_row[content]; } } } } else { // insert new product in database $insert = "INSERT INTO product (ean, name) VALUES('".$ean."', '".$name."')"; $doit = mysql_query($insert); } // free the result mysql_free_result($result); // close connection mysql_close($link); echo '<a style="font-size: 6px; color: white;" href="write.php?ean='.$ean.'">write</a>' ?>
- 4. change the login-data for the database in the "content.php"-script
- 5. login to the backend of AOM and create a custom box, change the box-type to "HTML/PHP File" and insert "content.php" in the box-content
- 6. create a file named "write.php" in the root-folder (where your content.php-file is too)
- 7. insert this code:
Code: Select all
<?php // MySQL-Connection $link = mysql_connect("your-hoster.de", "db-username", "db-password") or die("connection error"); mysql_select_db("db-name") or die("database dont exist"); $username = $_GET[username]; $password = $_GET[password]; //update content in database if(($_GET[written] == 1) && ($_GET[content_id] > 0)) { $query = "UPDATE content SET content = '".$_GET[content]."' WHERE id = '".$_GET[content_id]."'"; $res = mysql_query($query); echo 'Content updated'; } //insert new content in database else if($_GET[written] == 1) { $query = "INSERT INTO content (content) VALUES ('".$_GET[content]."')"; $res = mysql_query($query); $content_id = mysql_insert_id(); $query = "INSERT INTO pro_con_assoc (ean, content_id) VALUES ('".$_GET[ean]."', '".$content_id."')"; $res = mysql_query($query); echo 'Content created'; } //if logged in if($username == 'insert_username' && $password == 'insert_password') { $ean = $_GET[ean]; //select product name $p_quer = "SELECT product.name AS name FROM product WHERE product.ean = '".$ean."'"; $p_res = mysql_query($p_quer); while ($p_row = mysql_fetch_assoc($p_res)) { $product_name = $p_row[name]; } //check if content already exists and user want to change it $query = "SELECT product.name AS name, content.id AS content_id, content.content AS content FROM product, content, pro_con_assoc WHERE product.ean = '".$ean."' AND pro_con_assoc.ean = '".$ean."' AND pro_con_assoc.content_id = content.id"; $res = mysql_query($query); while ($row = mysql_fetch_assoc($res)) { $content_id = $row[content_id]; $product_content = $row[content]; } echo ' <form action="write.php" method="get"> <p>Product: '.$product_name.'</p> <p>Content:<br> <textarea name="content" rows="20" cols="80">'.$product_content.'</textarea></p> <input type="hidden" name="ean" value="'.$ean.'" /> <input type="hidden" name="username" value="'.$username.'" /> <input type="hidden" name="password" value="'.$password.'" /> <input type="hidden" name="written" value="1" /> <input type="hidden" name="content_id" value="'.$content_id.'" /> <input type="submit" value="post" /> </form> '; } //if not logged in - show login formular else { $ean = $_GET[ean]; echo ' <form action="write.php" method="get"> <p>Username:<br><input name="username" type="text" size="30" /></p> <p>Password:<br><input name="password" type="password" size="30" /></p> <input type="hidden" name="ean" value="'.$ean.'" /> <input type="submit" value="login" /> </form> '; } ?>
- 8. Change the MySQL-Connection Data in "write.php"
- 9. Change "insert_username" and "insert_password" to the username and password you like
- 10. Go to the product you want to add an article to, press "Controll + A" to select ALL text on the site. You'll find a link called "write", i hide this one, so no user see this (if your background color is white). Press the link, login and write your article. You can change the link, the color and the link-name by changing the "content.php" file at the bottom you'll find the code for the link
Note: I'll write a script to easily insert articles if enough users are interested in this