Paip. discuz item Development Guide-attilax Summary-
Today, I want to develop a discuz x2.5 project named "strong protest". The scenario is as follows: one day, someone saw a post posted by others and thought it was full of nonsense, as long as the "strong protest" item is used, the post will be hidden for a period of time, and everyone will not be able to see it ..
Start it.
Item Management Background: http: // 127.0.0.1/m_dx/admin. php
Management Center> operation> item center ..
Go to the item center and check out the "noisy Card". This item is taken as its original shape. Its image address is static/image/magic/open.gif, so I also made a "strong protest" image named del.gif and put it in its directory,
There is also a small image * .small.gif, which should be used for displaying small images on the frontend, as well as a small image del.small.gif.
Then, you need to add items. After searching, you can first check the official item development manual. Location: Welcome to discuz! Technical Library> 3. Welcome to discuz! Technology Library> 3.3 3.3 plug-in mechanism> development of third-party extension> item
The main notes are as follows:
Script location: Source/class/magic/*. php
Language Pack location: Source/Language/magic/*. php
..........................
............................
So, go to the source/class/magic/directory and put open. PHP. This is the "noisy" php. I copied it directly and renamed it Del. PHP, so that my script is almost ready. Open Del. PHP. After reading this article, there are three main lines to note ..
VaR $ name = 'open _ name'; // Item Name
VaR $ description = 'open _ desc'; // item description
'Title' => 'open _ Forum ', // item description
Then, go to the Language Pack location: Source/Language/magic /*. PHP: Copy lang_open.php. This is the language package of "noisy card", renamed lang_del.php, and changed the description of open_name, open_desc to your own...
Then usesubmit () in Del. php. This is the focus. It refers to the action code after the name item is used... Write down .. Write the action code ..
Then, I tested the item in the backend project center and found that there was already one more line. The item was displayed, and its name was "strong protest", but the picture was not displayed,
You have to debug to solve the problem of image rejection:
--------------- Debugging of item images cannot be displayed in the background -------------
1. admin. php
Require discuz_admincp-> admincpfile ($ action );
Return './source/admincp _'. $ action. '. php ';
2. Source/admincp/admincp_magics.php
Line 52 (file_exists (discuz_root. './static/image/magic/'.w.magic='identifier'{.'.gif ')? ' ':''),
Here is the image URL. You can click it at a breakpoint to see the specific situation...
3. I read the code for reading images and read the image process --------------
Discuz reads the name of the prop image, mainly based on the script location: Source/class/magic/*. php, come ,,,
The main code is as follows:
Source/admincp/admincp_magics.php
Function getmagics (){
Global $ _ g;
$ Dir = discuz_root. './source/class/magic ';
$ Magicdir = Dir ($ DIR );
$ Magics = array ();
While ($ entry = $ magicdir-> Read ()){
After my debugging, it turns out that the image file name is misspelled. Go back to static/image/magic/and change the image name. OK ..
In this case, the newly added item image is displayed on the backend item Center interface, and the following settings are saved... An English string open_desc cannot be changed .. However, I have set all the language packs. I checked the PHP file and found it was okay. I guess it should be in the database table, so I want to search the entire database for it .. Export the database as an SQL file and search for it. We found that open_desc is in the pre_common_magic table. Open the table and check it. Ah, the item settings are saved here... I guess it is the first time I saved the item settings, I saved the data here .. Then I changed open_desc and refreshed it back to the background. It was OK...
Then, you need to display the item on the front-end. In the background, you can display the item's display permissions, "allow the use of this item section:". Here, you can set the displayed section and item permissions, I have selected all of them ..
But at the front-end, I opened a post and tried to use items, but I found that there was no "strong protest" item .. I started debugging again. For convenience, I started tracking from CSS and HTML at the front end. I used ie9 and F12 to track "using items". The Code is as follows:
<P>
<A href = "javascript:;" id = "mgc_post_1" onmouseover = "showmenu (this. ID)" class = "showmenu"> use a prop </a>
</P>
<Ul id = "mgc_post_1_menu" class = "p_pop mgcen" style = "display: none;">
<Li> <a href = "home. php? MoD = magic & Mid = bump & idtype = TID & id = 1 "id =" a_bump "onclick =" showwindow (this. ID, this. href) "> Upgrade card </a> </LI>
<Li> <a href = "home. php? MoD = magic & Mid = stick & idtype = TID & id = 1 "id =" a_stick "onclick =" showwindow (this. ID, this. href) "> top card </a> </LI>
The key point is this <ul>. I retrieved all the files from its ID mgc_post_1_menu, but not from the database .... I guess it may be spliced, so I only retrieve the First Half of the mgc_post, and I found it in the PHP file: template \ Default \ Forum \ viewthread_node.htm. This is in the template. Open it and check that the nearby code is as follows, and then combine the judgment of class = "p_pop mgcen ..
<Ul id = "mgc_post _ $ post [pid] _ menu" class = "p_pop mgcen" style = "display: none;">
<! -- {If $ post ['first']} -->
<! -- {If! Empty ($ _ g ['setting'] ['magics '] ['del'])} -->
<Li> <a href = "...... "> ........ </A> </LI>
<! -- {/If} -->
<! -- {/If} --> I think there is a problem. It is not so troublesome to write HTML annotations. I think it should be a special module syntax to extract HTML from it ..
So I copied one of them <li> and changed it. Then I posted a picture on the front-end, YH, and finally OK. It is displayed and can be used ..
In this way, my first discuz x2.5 item development, the perfect result is achieved .........................
Attilax is written on 2012.7.9 pm