Restore Drupal's Blog comment mode

zhaozj2021-02-16  68

It has always been the most unsatisfactory DRUPAL is to reply with email. Otherwise, you can only answer, after all, Drupal is a blog-based system, not forum, so decided to return Blog's comment mode to Drupal, follow the style of MovableType Recreate the comment module.

Two points Description: 1, method is not official, please back up files in advance. 2, refer to Anonymous Comments Hack from DavidNunez

specific method:

1. Add 3 columns in the Comments table in the database: CNME, CEML, CURLSQL statement:

ALTER TABLE Comments Add Cnme Varchar (60) Default NULL;

ALTER TABLE Comments Add Ceml Varchar (64) Default NULL;

Alter Table Comments Add Curl Varchar (255) DEFAULT NULL;

2. Change Includes / Common.inc

Replace it in the format_name method:

Function Format_name ($ Object) {

IF ($ Object-> Uid && $ Object-> Name) {/ * * * Shorten the name when is too long or it will break body ** tables. * /

IF (Strlen ($ Object-> Name)> 20) {$ name = truncate_utf8 ($ Object-> Name, 15). "...";} else {$ name = $ Object-> name;}

IF (arg (0) == "Admin" and user_access ("administer users")) {$ OTPUT = L ($ name, "admin / user / edit / $ object-> uid", array ("title" => T ("Administer User Profile."))))));} else {$ OUTPUT = L ($ Name, "User / View / $ Object-> UID", array ("Title" => T ("View User Profile." ))));}} Else if ($ Object-> name) {/ * ** Sometimes Modules Display Content Composed by People Who Are ** Not Registers Members of The Site (IE Mailing List or news ** aggregator modules). This Clause Enables Modules to Display ** The True Author of the content. * /

$ output = $ Object-> name;} // ****** HACK ELSE IF ($ Object-> CNME) {if ($ Object-> curl) {$ POS = STRPOS ($ Object-> curl, " http: // "); if (IS_INT ($ POS)) {$ OTPUT = L ($ Object-> CNME," $ Object-> CURL ");} else {$ OUTPUT = L ($ Object-> CNME, "curl /"> http:// $ Object-> curl ");}} else {$ output = $ object-> cnme;}} // ****** * END HACK ELSE {$ Output = T (Variable_Get ("Anonymous", "Anonymous"));} Return $ OTPUT;}

3. Replace the theme_comment_form method in modules / comment.module:

Function theme_comment_form ($ Edit, $ TITLE) {Global $ USER;

$ form. = "/ n";

// ****** HACKED // Name Field: // $ form. = Form_item (t ("Your Name"), format_name ($ user));

IF ($ usr-> name)) {$ form. = form_item (t (t ("Your Name"), format_name ($ us));} else {$ form. = form_textfield (t ("Your Name") , "CNME", $ Edit ["CNME"], 50, 64); $ form. = form_textfield ("e-mail (optional)"), "CEML", $ Edit ["CEML"], 50, 64); $ form. = Form_textfield (T ("Web Site (optional)"), "CURL", $ Edit ["curl"], 50, 64, "be suhe to start with http: //");} // ******

// Subject Field: $ form. = form_textfield (T (Subject ")," Subject ", $ Edit [" Subject "], 50, 64);

// Comment Field: $ form. = form_textarea (T ("Comment"), "Comment", $ Edit ["comment"]? $ Edit ["Comment"]: $ USER-> Signature, 70, 10, Filter_tips_short ));

// Preview Button: $ form. = form_hidden ("CID", $ Edit ["CID"]); $ form. = form_hidden ("pid", $ Edit ["PID"]); $ form. = form_hidden (" NID ", $ Edit [" NID "]); if (! $ edit [" comment "] && variable_get (" comment_preview ", 1)) {$ form. = form_submit (t (" preview comment ");} else {$ Form. = Form_submit (t ("preview comment"); $ form. = Form_submit (t ("post Comment");}

Return Theme ("Box", $ TITLE, FORM ($ FORM, "POST", URL ("comment / reply /". $ Edit ["NID"])));}

4. Replace the corresponding statement in Modules / Comment.Module (Note Is DB_QUERY INTO statement

DB_Query ("Insert Into {Comments} (CID, NID, PID, UID, Subject, Comment, Hostname, Timestamp, Status, Score, Users, Thread, CNME, CEML, CURL)

VALUES (% D,% D,% D,% D, '% s','% s', '% s',% D,% D,% D,'% s', '% s','% S ','% s', '% s') ", $ Edit [" CID "], $ Edit [" NID "],

$ Edit ["PID"], $ User-> Uid, $ Edit ["Subject"], $ Edit ["comment"],

$ _SERVER ['Remote_addr'], Time (), $ Status, $ SCORE, $ USERS, $ THREAD, $ Edit ["CNME"], $ Edit ["CEML"], $ Edit ["curl"]);

5. Change the theme template file used

If you are using xTemplate, change the corresponding method within xTemplate.Theme:

Function Xtemplate_Comment ($ Comment, $ LINKS = 0) {Global $ XTemplate;

// ********** Hack $ Result = db_fetch_object (DB_Query ("SELECT * from comments where cid =% d", $ comment-> CID);

$ comment-> cnme = $ results-> cnme; $ comment-> curl = $ result-> curl; $ comment-> ceml = $ result-> ceml; // ********** End Hack

$ xtemplate-> template-> assign ("new" => t ("new"), "submitted" => t ("Submitted BY% a on% b.", array ("% a" => format_name ($ comment), "% b" => format_date ($ comment-> timestamp)), "Title" => $ comment-> Subject, "Author" => format_name ($ comment), "Date" => format_date ($ comment-> timestamp), "content" => $ comment-> Comment)); if ($ comment-> new) {$ xtemplate-> template-> parse ("comment.new");}

IF ($ Picture = Theme ('user_picture ") {$ xtemplate-> template-> Assign (" Picture ", $ Picture; $ xtemplate-> template-> parse (" comment.picture ");}

IF ($ links) {$ xtemplate-> template-> assign ("links", $ links); $ xtemplate-> template-> parse ("comment.links");}

$ xtemplate-> template-> parse ("comment"); $ output = $ xtemplate-> template-> text ("comment"); $ xtemplate-> template-> recst ("comment");

Return $ OUTPUT;

If you use PHPTemplate to change the corresponding method within phpTemplate.Theme to:

Function PHPTemplate_comment_view ($ Comment, $ LINKS = ", $ visible = 1) {

// ********** Hack $ Result = db_fetch_object (DB_Query ("SELECT * from comments where cid =% d", $ comment-> CID);

$ comment-> cnme = $ results-> cnme; $ comment-> curl = $ result-> curl; $ comment-> ceml = $ result-> ceml; // ********** End Hack

$ output = ""; if (node_is_new ($ comment-> nid, $ comment-> timestamp) {$ comment-> new = 1;}

IF ($ visible) {$ comment-> comment = check_output ($ comment-> comment); $ output. = Theme ("Comment", $ comment, $ links);} else {$ output. = theme ("comment_folded" $ comment);} return! DONE!

转载请注明原文地址:https://www.9cbs.com/read-17281.html

New Post(0)