| Topic: | Duplicating the Reviews module |
|---|---|
|
rs323
Freshman
Posts: 3 Posted: |
Hello there all. I'm just getting into PostNuke and I must say that I love this system. I'm setting up a website right now which should provide reviews into different categories. I have tried to get into that Pagesetter module to get different review categories, but it's too much since I like the simplicity of the standard review system that comes with PostNuke. So, I copied the Reviews folder and named the copy TCReviews. I went into all the .php files and made sure the entire code remains intact EXCEPT for one thing: To make it use different tables. Rather than using pn_reviews, it would use pn_tcreviews. I did this in the pninit.php file as well, and while I can initialize and activate it, no tables are being created into the database. Am I overlooking something in here? Was it a mistake to change the variable $reviews into $tcreviews? To me it wouldn't make sense if that's causing trouble though. Codefunction Reviews_init() { // Get database information $dbconn =& pnDBGetConn(true); $pntable =& pnDBGetTables(); // Create tables $tcreviews_table = $pntable['tcreviews']; $tcreviews_column = &$pntable['tcreviews_column']; $sql = "CREATE TABLE $tcreviews_table ( $tcreviews_column[id] int(11) NOT NULL auto_increment, $tcreviews_column[date] datetime NOT NULL default '0000-00-00 00:00:00', $tcreviews_column[title] varchar(150) NOT NULL default '', $tcreviews_column[text] text NOT NULL, $tcreviews_column[reviewer] varchar(20) default NULL, $tcreviews_column[email] varchar(60) default NULL, $tcreviews_column[score] int(11) NOT NULL default '0', $tcreviews_column[cover] varchar(100) NOT NULL default '', $tcreviews_column[url] varchar(254) NOT NULL default '', $tcreviews_column[url_title] varchar(150) NOT NULL default '', $tcreviews_column[hits] int(11) NOT NULL default '0', $tcreviews_column[rlanguage] varchar(30) NOT NULL default '', PRIMARY KEY (pn_id))"; $dbconn->Execute($sql); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed initialisation attempt return false; } $tcreviews_add_table = $pntable['tcreviews_add']; $tcreviews_add_column = &$pntable['tcreviews_add_column']; $sql = "CREATE TABLE $tcreviews_add_table ( $tcreviews_add_column[id] int(11) NOT NULL auto_increment, $tcreviews_add_column[date] datetime default NULL, $tcreviews_add_column[title] varchar(150) NOT NULL default '', $tcreviews_add_column[text] text NOT NULL, $tcreviews_add_column[reviewer] varchar(20) NOT NULL default '', $tcreviews_add_column[email] varchar(60) default NULL, $tcreviews_add_column[score] int(11) NOT NULL default '0', $tcreviews_add_column[url] varchar(254) NOT NULL default '', $tcreviews_add_column[url_title] varchar(150) NOT NULL default '', $tcreviews_add_column[rlanguage] varchar(30) NOT NULL default '', PRIMARY KEY (pn_id))"; $dbconn->Execute($sql); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed initialisation attempt return false; } $tcreviews_comments_table = $pntable['tcreviews_comments']; $tcreviews_comments_column = &$pntable['tcreviews_comments_column']; $sql = "CREATE TABLE $tcreviews_comments_table ( $tcreviews_comments_column[cid] int(11) NOT NULL auto_increment, $tcreviews_comments_column[rid] int(11) NOT NULL default '0', $tcreviews_comments_column[userid] varchar(25) NOT NULL default '', $tcreviews_comments_column[date] datetime default NULL, $tcreviews_comments_column[comments] text, $tcreviews_comments_column[score] int(11) NOT NULL default '0', PRIMARY KEY (pn_cid))"; $dbconn->Execute($sql); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed initialisation attempt return false; } $tcreviews_main_table = $pntable['tcreviews_main']; $tcreviews_main_column = &$pntable['tcreviews_main_column']; $sql = "CREATE TABLE $tcreviews_main_table ( $tcreviews_main_column[title] varchar(100) default NULL, $tcreviews_main_column[description] text)"; $dbconn->Execute($sql); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed initialisation attempt return false; } // Insert needed data $result =& $dbconn->Execute("INSERT INTO $tcreviews_main_table VALUES ( '"._REVIEWSMAINTITLE."', '"._REVIEWSMAINDESC."')"); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed initialisation attempt return false; } // Set up config variables // Initialisation successful return true; } /** * upgrade */ function Reviews_upgrade($oldversion) { return true; } /** * delete the reviews module */ function Reviews_delete() { // Get database information $dbconn =& pnDBGetConn(true); $pntable =& pnDBGetTables(); // Delete tables $sql = "DROP TABLE $pntable[tcreviews]"; $dbconn->Execute($sql); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed deletion attempt return false; } $sql = "DROP TABLE $pntable[tcreviews_add]"; $dbconn->Execute($sql); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed deletion attempt return false; } $sql = "DROP TABLE $pntable[tcreviews_comments]"; $dbconn->Execute($sql); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed deletion attempt return false; } $sql = "DROP TABLE $pntable[tcreviews_main]"; $dbconn->Execute($sql); // Check database result if ($dbconn->ErrorNo() != 0) { // Report failed deletion attempt return false; } // Delete module variables // Deletion successful return true; } ?> edited by: rs323, Mar 12, 2007 - 01:27 PM |
|
kaffeeringe.de
Professional
Posts: 900 Posted: |
Welcome to the PostNuke community! You should search and replace every instance of "reviews" with "tcreviews" through-out the whole module. That is needed because the module files of course access the tables. -- best regards from Kiel, sailing city Steffen Voss Member of the PostNuke Steering Committee Read The Zikulan's Blog |
|
rs323
Freshman
Posts: 3 Posted: |
I did, but that's not working properly. Also, I want it to use the same permission rules as the original review system does. It's strange that it doesn't even create the tables specified in the pninit.php file. Desperately, I renamed the Reviews_init function to TCReviews_init function, but that also didn't provide anything. But I knew that that wasn't going to do it either. Isn't there some kind of script or table on which the reviews module depends on? Since it's a official module after all... |
|
kaffeeringe.de
Professional
Posts: 900 Posted: |
mmmh. okay. That makes it more manual work. 1. edit all instances of the table names in init.php and pntables.php 2. edit all instances of the table name in the other module files, without touching the other instances of the modules's name. -- best regards from Kiel, sailing city Steffen Voss Member of the PostNuke Steering Committee Read The Zikulan's Blog |
|
rs323
Freshman
Posts: 3 Posted: |
I got it working now. The duplication is completed. It works smooth, but there's one problem... It doesn't seem to add user-posted reviews to the 'Waiting Content' block. |