Typecho adds the function of displaying comment user URL

2021-05-17 10:14:57 read 0 Comments two

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:

 Typecho adds the function of displaying comment user URL

<\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.

 Typecho adds the function of displaying comment user URL

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)

 Typecho adds the function of displaying comment user URL

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:

 Blog comment 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

Article copyright notice: unless otherwise noted Lin Yufan For original articles, reprints or copies, please use hyperlinks and indicate the source.
 Lin Yufan

Lin Yufan V

Lin Yufan's blog is an original independent blog recording his own life and Internet technology Com

four thousand two hundred and fifty-nine article
sixteen thousand seven hundred and sixty-eight comment
twenty million eight hundred and fifty-nine thousand four hundred and eight browse

Understand?

  •  Understand?

High quality server recommendation

  •  SoftCloud_RuanCloud

Active friends

Latest comments

    Your comment area is slow to load, and the browser status box displays soft cloud. Are you still using soft cloud?
    sagrre • Time June 15, 2024 07:32:36
    Don't you use hosts to test before changing the domain name resolution?
    Shiying Lantern • Time 15:37:14, June 12, 2024
    The small program is god horse. I have also encountered a strange problem before. The PC terminal and the simulator have no problem opening. All interfaces on the mobile phone reported errors. That time, it was an SSL certificate problem. The problem was solved by replacing the certificate.
    Ha ha ha. Sometimes there is a problem. Although it seems to be a headache, it may be a headache caused by feet.
    obaby • Time 13:50:31, June 11, 2024
    We can only bask in the achievements of the Big Boss Heo lifting glasses:
    Rice with Zongye • Time 08:56:16, June 11, 2024
    This may be a problem with the local operator's server
    Pampo • Time 20:40:27, June 10, 2024
    This is full of interface callbacks.
    Summer Blog • Time 19:29:05, June 10, 2024
    Good thing: heo monk:
    Eternal End Dagger • Time June 9, 2024 18:01:30
    Where did you add the CSS
    dilingtian • Time 11:13:27, June 8, 2024
    Big guy's whole life is efficient Hey - Unbelievable:
    Rice with Zongye • Time 10:11:30, June 8, 2024
    There was a period of time ago when Skynet's onedrive service was unavailable.
    Netizen Xiao Song • Time 22:34:45, June 6, 2024
    https://boce.aliyun.com/home You can use this to check the DNS. If the old DNS is still used, the network server is not refreshed. If the local ping is an old dns, but Alibaba Cloud displays a new dns here, it means that there is a problem with the local broadband and computer: hey - glasses:
    Wind records stars • Time June 6, 2024 18:23:41
    https://boce.aliyun.com/home You can use this to check the DNS. If the old DNS is still used, the network server is not refreshed. If the local ping is an old dns, but Alibaba Cloud displays a new dns here, it means that there is a problem with the local broadband and computer: hey - glasses:
    Wind records stars • Time June 6, 2024 18:23:28

Learn more?

  •  Lin Yufan to do
 cancel
 Alipay QR code
 Alipay QR code
 WeChat QR code