reminder:
Last updated 2021-05-17 10:14:57 , if the content or picture is invalid, please leave a message for feedback!
See today Uncle Qin It was said on the blog that it was a new theme, but the URL submitted by the user was not displayed.
Later, I installed the Typecho program locally, and found that the background of the program is as simple as its foreground, and there is no way to set the display URL in the background. So let's just write the code.
Look at the Typecho database. It should support the user comment submission URL. This field is available.
The category is used by Uncle Qin Others' themes This theme is very beautiful.
Here's how to modify it:
1、 Front desk modification
Open the \usr\themes\Joe-master\public\comment.php File:
Add a line of URL form anywhere the user submits information:
<\div class="list"> <\input type="text" value="{C} user->hasLogin() ? $ this->user->url() : $this->remember('url') ?> "Autocomplete=" off "name=" url "placeholder=" Please enter the URL " /> <\/div>
To prevent the above code from being parsed into Html, I add Backslash 。
2、 Modify the front end submission js file
open \Joe-master\assets\js\joe.global.js File, modify as shown in the figure below.
explain:
Line 1, Replace the original url Replace a new word, and the author of this topic url Used as Ajax The submission address of the, resulting in the following database fields url It's not easy to use.
Line 2, Add a new line to get the form information, because the above is changed url Variables can be directly used here. Code:
const url = $(".joe_comment__respond-form .head input[name='url']").val();
Line 3: Modify the Ajax submission address to the variable address we defined above.
Line 4: increase url Variable.
The above is modified joe.global.js File, if the blog references joe.global.min.js File, remember to modify usr\themes\Joe-master\public\include.php References in files Js file name Of course, the above modification can directly compress and replace the min file.
The following shows the URL. I found that Typecho The URL is not displayed by default.
3、 Modify backend file
open \var\Widget\Abstract\Comments.php File, find the author's output function:
function author($autoLink = NULL, $noFollow = NULL)
e c h o '<\a target="_blank" href="' , $this->url , '"' , ($noFollow ? ' rel="external nofollow"' : NULL) , '>' , $this->author , '<\/a>';
Directly modify the latter judgment, and all users will display the URL.
Final effect:
Update 2021.5.18
1、 No modification is required for either the development version or the official version var\Widget\Abstract\Comments.php File.
2、 When the subject author updates the subject, the original verification method of addition is updated to a 4-digit verification code, but the form submission process is the same.
Reference address:
1、 https://notemi.cn/add-a-blogger-and-a-friend-to-your-comments.html