[Secondary Development] how to display the author's profile picture on the dede Article Page

Source: Internet
Author: User

Dede shows on the article page that the author only displays the user name, but if I want to transform dede into a more social website, I think it is necessary to show the author's profile picture, however, the official website does not have the corresponding template tag.
On the Internet, we can see that the solution to this problem is basically to directly call the runphp program segment on the template page. Indeed, this method is feasible.
But I am not inclined to do this, because many times we need differentiated functions, and every time such a mix of php code looks messy.

I modified it directly in the PHP file so that the Article template can call several new labels.
Find the/include/arc. archives. class. php file.
Search for "$ this-> addTableRow = $ this-> dsql-> GetOne ($ query);" and jump to about 154 rows, add the following code under else {$ this-> Fields ['templet'] = $ this-> Fields ['redirecturl'] =:

/* HEJIE_MODIFY author information @ www.68cpu.com */$ query = "SELECT * FROM jcode_member WHERE 'mid '= ". $ this-> Fields ['mid ']; $ authorInfo = $ this-> dsql-> GetOne ($ query ); $ this-> Fields ['authorance'] = $ authorInfo ['uname']; $ this-> Fields ['authorface'] = $ authorInfo ['face']; if (empty ($ this-> Fields ['authorface']) {$ this-> Fields ['authorface'] = ($ this-> authorInfo ['sex'] = 'female ')? '.. /Member/templets/images/dfgirl.png ':'.. /member/templets/images/dfboy.png ';} $ this-> Fields ['authorface'] = "<a href = '". $ GLOBALS ['cfg _ basehost']. "/member/index. php? Uid = ". $ authorInfo ['userid']. "'>  Fields ['authorface']. "'/> </a>"; $ this-> Fields ['authoremail'] = $ authorInfo ['email '];

The purpose of this Code is to query the author information based on the Author id, including the Avatar.
I found three types of profile email and user name for future use.
I have done some processing in the label of the user avatar, so that the link can be directly generated when called in the template, pointing to the author's space.
The statement for calling the author's profile picture in the article template is:
{Dede: field. authorface /}
The php code corresponding to this tag is actually the above $ this-> Fields ['authorface'], similarly, we need to query the author's email information. In the php code $ this-> Fields ['authoremail '], the corresponding template tag is {dede: field. authoremail /}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.