Dede list article self-increment

Source: Internet
Author: User

In {dede:arclist/} this tag has a [field:global.autoindex/], which is starting from 0, if we want to customize a value, such as custom starting from 2. Then you can write the following code:

[Field:autoindex runphp= ' yes '] @me = $GLOBALS [' AutoIndex ']+2; [/field:autoindex]

Description: +2 represents starting from 2, 1 is representing starting from-1.

Note: This self-growth needs to be between your loop list start and end!

in {dede:arclist/} This tag everyone knows there is a [field:global.autoindex/], this variable each generated a row of + 1, that many people want {dede:sql/} tag also need to add this function, many friends ask questions, Will certainly think that the official will not do, in fact, the official main hope that we can share this use, development of the small skills, small experience, actually this thing is very simple, you can find out a little bit.
Here we begin to add this small extension, we know that the V5.3 in the dream of the label has been separated, that is, similar to arclist such a label can be modified or two times development, the program these tags stored in the directory under the/include/taglib folder, We can look at that file name, it is easy to know the tag file name and the corresponding relationship between the label.
now we need to modify the {dede:sql/} This tag, then we will modify sql.lib.php this file.
when we open it, we find the 34th line, the code.
$CTP->loadsource ($Innertext);
, add the following snippet below:
$GLOBALS [' autoindex '] = 0;
This code defines a global variable and assigns a value of 0, and then we just need to modify the following code:
While ($row = $dsql->getarray ($THISRS))
 {
$sqlCt + +;
foreach ($ctp->ctags as $tagid = + $ctag) {
if (!empty ($row [$ctag->getname ()]) {$CTP->assign ($tagid, $row [$ctag->getname ()]);}
  }
$GLOBALS [' AutoIndex ']++;//Each loop is added with one 1 at a time and parsed out
$revalue. = $CTP->getresult ();
 }
In this way, the [field:global.autoindex/] tag can be used in that {dede:sql/}, and we'll give you an example:
{dede:sql sql= ' select * from

#@__archives '

}
[field:global.autoindex/]-[field:title/]</br>
{/dede:sql}
What do you think? Very simple, actually this kind of extension still has many many, oneself may try oh.

[Field:global name=autoindex runphp= "yes"]@[email protected]+1; [/field:global]

{Dede:global Name=itemindex runphp= "yes"}@[email protected]+1; {/dede:global}

AutoIndex ItemIndex of the use of the difference of experience

Under the channelartlist tag, use {Dede:global name= ' itemindex ' runphp= ' yes ' @me; {/dede:global}

Self-increment 1

Arclist tag using [field:global.autoindex/] default starting from 1
Channel label using [field:global.autoindex/] default starting from 0
Using {dede:global.itemindex/} under the Channelartlist tab starts from 1 by default

Arclist starting from 0 [Field:global name=autoindex runphp= "yes"]@[email protected]; [/field:global]

Channel starting from 1 [field:global name=autoindex runphp= "yes"]@[email protected]+1; [/field:global] [field:typename/]

Channelartlist starting from 0 {dede:global name=itemindex runphp= ' yes '}@[email protected]; {/dede:global}

<div id= "h_pd_lm_{dede:global.itemindex/}" {Dede:global name= ' itemindex ' runphp= ' yes '} @me = (@me ==1)? ': ' style= ' Display:none, "'; {/dede:global} class= "Pd2_lmc_l1" >

eg---->

{dede:channelartlist notypeid= ' 123,124,146,147 '}
<a class= "Pd2_lmt{dede:global name=itemindex runphp= ' yes '} @me = (@me ==1)? ' 1 ': ' 3 '; {/dede:global} "onmouseover=" Showitem2 ({dede:global name=itemindex runphp= ' yes '}@[email protected];{ /dede:global}, ' Pd_lm ', ' h_pd_lm_ ', ' pd2_lmt '); ' href= ' {dede:field name= ' typeurl '/} ' >
{dede:php}if ($refObj->fields[' Ispart ') {echo $refObj->fields[' TypeName '];} {/dede:php}
</a>
{/dede:channelartlist}

{dede:channelartlist typeid= "1" row= "8"}
<div class= "combz01" {dede:global name=itemindex runphp= ' yes '}if (@me ==2) @me = ' id= ' with '; if (@me ==5) @me = ' id= ' With "'; if (@me ==7) @me = ' id=" with "; {/dede:global}>
<div class= "Combz01title" ><a href= "{dede:field name= ' typeurl '/}" title= "{Dede:field name= ' typename '/}" target= "_blank" ><b>{dede:field name= ' TypeName '/}</b></a><u><a href= "{Dede:field Name= ' Typeurl '/} "title=" {Dede:field name= ' typename '/} ' target= ' _blank ' > more >></a></u></div >
<div class= "Comcon" >
{dede:arclist titlelen= ' row= ' 1 ' flag= ' C '}

<i>[field:description function= "Cn_substr (@me, +)"/]...<a href= "[Field:arcurl/]" title= "[Field: fulltitle/] "target=" _blank ">[details]</a></i>
{/dede:arclist}
</div>
<div class= "Comconlist" >
<ul>
{dede:arclist titlelen= "row=" 3 "}
<li><a href= "[Field:arcurl/]" >[field:title/]</a></li>
{/dede:arclist}
</ul>
</div>
</div>
{/dede:channelartlist}

Using the channel label [Field:global name=autoindex/]

eg---->

{dede:channel titlelen= ' 32 '}
<li [Field:global name= ' autoindex ' runphp= ' yes ']if (@me%2==0) {@me = ' class= ' RR ';} else{@me = ';} [/field:global] >
{/dede:channel}

This is the way to use AutoIndex runphp in arclist:

{dede:arclist titlelen= ' row= ' 4 ' flag= ' C ' orderby= ' ID '}
<a href= "[Field:arcurl/]" target= "_blank" >[field:title/]</a>
[Field:global name= ' autoindex ' runphp= ' yes ']if (@me ==2) {@me = "<br/>";} else{@me = ';} [/field:global] {/dede:arclist}

Self-increment 1

[field:global.autoindex/]

eg

{dede:arclist channelid=17 row=6 orderby=pubdate titlelen=40 addfields= ' Docphoto,docjob,doctec ' typeid= ' 123,136,146,155,172,182,202 '}
<div id= "h_nrr_zj_[field:global.autoindex/" "class=" Nrr_zjl "[Field:global name= ' autoindex ' runphp= ' yes ']if (@me = =1) {@me = "";} else{@me = ' style= ' Display:none; ';} [/field:global] >
<div><a href= "[field:arcurl/]" title= "[field:fulltitle/]" target= "_blank" ></a></div>
</div>
{/dede:arclist}

How to define the starting number freely

Autoindex/itemindex can use @me +1; implementation starts with the specified number

Encounter similar problems to do this note, in the use of the time can be flexible to play!

Try AutoIndex under the List tab

{dede:list pagesize= ' orderby= ' ID '}

[Field:global name= ' autoindex ' runphp= ' yes ']if (@me%10==0) {@me = "Test";} else{@me = ';} [/field:global]

{/dede:list}

Excerpt from: http://my.oschina.net/lyx2012/blog/55888/

Dede list article self-increment

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.