PHPCMS2008 making labels and label templates
Tag Setup Tutorials
We go from simple to complex
The first type: Chinese label
This is simple enough, that is, by setting the tag parameter in the background call
By choosing to read the segment to make the call, where the settings are Chinese characters, we are all people, we will not say more.
Columns commonly used variables to indicate that $catid can be called with this variable, or can be specified under a column, with a variable call, it will be based on the current page of the column to obtain the ID to be based on your label set conditions to display
Categories commonly used variables represent: $typeid the same
Area common variable representation: $areaid
Thumbnail commonly used variable representation: $thumb This is the selection criteria, you choose to call the image of the article, the information class
The publisher commonly used variable means: $userid call the designated member, you can also view a member's things to use
Update time Common variable representation: $updatetime publish time Common variable is expressed: $inputtime call the specified day of the
Recommended bit commonly used variable means: $posids The recommended location, when publishing the article has a recommended location selection, here you can call the
Sort by ID, time, number of visits, and so on, depending on the location of the different calls. Such as: ranking, the number of visits, the latest in descending order by release time
Paging shows the number of calls this needless to say, I know the word.
Label template here is the label you are going to call which tag template, in what form to call, the new tag template will also be shown here. such as: My new label template is called Tag_content_w3zz.html, which saves the style I want to display, here you can choose to call this template
Custom variables This is the power of 2008, and we can define our own variables. Which variables you want to define, but you have to remember that the variables here are the variables you use to determine the tags in your template, such as: Word count, whether it is displayed, how the link opens, the time format, and so on.
The custom fields set here must be kept in mind, be sure to correspond with the label template, otherwise there is no display.
The second type: through custom SQL calls
It should be all right if you understand SQL.
Now I have an example of how to write such a SQL
First, invoke the contents of a data table:
Such as: Call the picture column picture
SELECT contentid,title,style,thumb,url from ' content ' WHERE ' status ' =99 and ' thumb '! = ' ORDER by ContentID DESC '
Here I query the content ID, title, style, thumbnail, link address here the field can be in the background system settings-system Tools-data dictionary to see the fields of the data table to understand, here can also be compared with the background set tag parameters called fields to write
Select is a php query function
ContentID These are the things you want to find out, if you want to query all the use of *, all the contents of the field query out
From ' phpcms_content ' This is from the data table ' phpcms_content ' inside the query, you want to query which data table to write which data table
The WHERE ' status ' =99 and ' thumb '! = ' This is a query condition, status is a state, such as: Audit through and is connected to multiple query conditions, is and the relationship, while meeting can, there is either or is or, satisfies a number of conditions of one can be.
ORDER BY ContentID DESC This is a sort of way, here can also control, through the background to set the order of the label can be. DESC is descending, ASC is ascending
The second type: query two data tables
SELECT A.contentid,a.title,a.style,a.thumb,a.updatetime,b.unit,b.price,a.description,a.inputtime,b.stars,a.url From ' Pc_content ' A, ' pc_c_product ' b WHERE a.contentid=b.contentid and ' status ' =99 and ' thumb '! = ' ORDER by A.contentid D Esc
In fact, compared to the first case, it is similar to the data table processing, while querying two tables
Understand the first, this is also simple, is to define the table ' pc_content ' as a,pc_c_product defined as B, and then query the two tables in the fields you need, such as A.contentid,,b.price
A.contentid=b.contentid condition This is the field associated with the two tables, which is why the query is made with such SQL, the most important of which is this. It can be said that SQL is a related query.
Label Template Tutorials
Take the label template of my new effect as an example
Tag Template code: (Analyze the label template)
{loop $data $n $r}
Circulation, many people pick up and ask $data $n $r What is the meaning of these three parameters, because he did not look at the program, just look here I do not know what the meaning. So I read the program. $daTA is the program through the query, that is, the label settings set out in the SQL query results are stored in the form of an array in this. $n is the number of columns, 08 is the beginning of the 1th, this is a little different from 07, 07 is starting from 0, so if you want to write a judgment on this should pay attention to. such as: I want to show a line 5 of the judgment will be written as {if $n%5==1}{/if}. $r is the variable that you save the value of the loop, which is related to the subsequent display, so the variables here must be paid attention to and correspond to the latter.
Show Picture {thumb ($r [thumb], $width, $height)} thumbnail function, three parameters are, picture, width, height
{if $r [style]} {str_cut ($r [title], $titlelen, ')} {Else} {str_cut ($r [title], $titlelen, ')} {/if}
The title display {if $r [style]} This judgment is to determine whether you add a style, that is, color and bold, if you have to give the style to display, otherwise, according to the CSS file display. {str_cut ($r [title], $titlelen, ')} intercepts the title and intercepts it according to the Titlelen we added in the custom field, the system is {str_cut ($r [title], $titlelen)} and the ellipsis is displayed. If you don't want the ellipsis, use mine.
{if $showprice}
¥{$r [Price]} meta/{$r [Unit]}{/if}{if $showcart}
Show Price {if $showprice} determine whether to display Showprice set a value other than 0 in a custom field
{/if}
Displays the two pictures, links, which are purchased, which are all referenced to the purchase settings on the content page.
{/loop}
End the cycle, this can not be less yo, less can not be updated, pay attention to integrity, where all should be noted
{if $pages}
{$pages}
{/if}
Whether the page is displayed, this is set at the label settings
In fact, I just give the default product label template to add a few judgment display, and other product labels can also be used to display the content I want
My custom fields are:
So my label will come out.
It looks pretty simple.