destoon¹Ù·½±êÇ©´óÈ«

5年以前  |  阅读数:481 次  |  编程语言:PHP 

ʲôÊDZeÇ(C)µ÷Óã¿

±eÇ(C)µ÷ÓÃÊǸu¾Ýµ÷ÓÃÌo¼þ(condition)´ÓÊý¾Ý±i(table)¶ÁÈ¡µ÷ÓÃÊýÁ¿(pagesize)ÌoÊý¾Ý£¬²¢°´ÅÅÐo½Ê½(order)ÅÅÐo£¬×iÖÕͨ¹ý±eÇ(C)Ä£°aµÄ²¼¾ÖÊa³oÊý¾Ý¡£
¿ÉÒÔ¿´³o£¬±eÇ(C)µÄ¹¤×÷
ÖÁ½¸o²¿*Ö£¬Ò»ÊǶÁÈ¡Êý¾Ý£¬¶þÊÇÏÔʾÊý¾Ý¡£
±eÇ(C)º¯ÊýÔ­ÐÍ

±eÇ(C)º¯Êý±£´aeÓÚ include/tag.func.php
tag($parameter, $expires = 0)
$parameter ±iʾ´«µÝ¸øtagº¯ÊýµÄ×Ö*u´®£¬ÏµÍ³×Ô¶¯½«Æaת»»Îª¶a¸o±aÁ¿
ÀýÈç´«µÝ table=destoon&pagesize;=10&hello;=world
ϵͳÏaµ±Óڵõ½
$table = ¡®destoon';
$pagesize = 10;
$hello = ¡®world';
Èý¸o±aÁ¿
$expires ±iʾ±eÇ(C)»º´ae¹ýÆÚʱ¼a>0 »º´ae$expiresÃe£»0 ¨C ϵͳĬÈϱeÇ(C)»º´aeʱ¼a£»-1 ¨C ²»»º´ae£»-2 ¨C »º´aeSQL½a¹u£»
Ò»°aÇe¿o±£³ÖĬÈϲ»ÐeÒª´«µÝ¡£


Êý¾Ý¶ÁÈ¡¹ý³Ì

ÀýÈçÒÔϱeÇ(C)£º


    <!¨C{tag(¡°table=sell&condition;=status=3&order;=addtime desc&pagesize;=10¡a)}¨C>

»a±»×ª»»ÎªÈçϵÄSQLÓi¾a£º


    SELECT *
    FROM destoon_sell
    WHERE status=3
    ORDER BY addtime DESC
    LIMIT 0,10

¶Á³oµÄÊý¾Ý»a±£´aeÔÚ $tags Êý×eÀi
Êý¾ÝÏÔʾ¹ý³Ì

1¡¢Í¨¹ý±eÇ(C)Ä£°aÏÔʾ
´«µÝ&template;=abc¸ø±eÇ(C)º¯Êý£¬ÀýÈ磺


    <!¨C{tag(¡°table=¡­&template;=abc¡±)}¨C>

ĬÈϵıeÇ(C)Ä£°a±£´aeÔÚÄ£°aĿ¼/tag/Ŀ¼Ài£¬ÀýÈç&template;=abc½«µ÷ÓÃÄ£°aĿ¼/tag/abc.htmÄ£°aÀ´ÏÔʾÊý¾Ý
Èç¹u±eÇ(C)Ä£°a*ÅÓÚÆaËuĿ¼£¬ÀýÈçdef£¬Ôo´«µÝ&dir;=def&template;=abc£¬ÏµÍ³½«µ÷ÓÃÄ£°aĿ¼/def/abc.htmÄ£°a
*
2¡¢Ö±½ÓÔÚÄ£°aÀiÑ­»
Êý¾Ý
**


    <!¨C{php $tags=tag(¡°table=¡­&template;=null¡±);}¨C>


´Ëд¨´«µÝ±eÇ(C)Ä£°aΪnull£¬²¢ÇÒÖ±½Óµ»ØÊý¾Ý¸ø$tagsÊý×e£¬´Ëʱ¿ÉÒÔÖ±½ÓÔÚÄ£°aÀiÑ­»*ÁË
ÒÔÏÂΪһ¸oÍeÕuµÄʾÀý£º


    <!¨C{php $tags=tag(¡°table=¡­&template;=null¡±);}¨C>
    {loop $tags $t}
    ¡­
    {/loop>

µÚÒ»ÖÖд¨Ò»°aÓÃÓÚ¶a´Îµ÷ÓõÄÊý¾Ý£¬µÚ¶þÖÖд¨Ò»°aÓÃÓÚÖ»µ÷ÓÃÒ»´ÎµÄÊý¾Ý¡£
³£ÓòÎÊý¼°º¬Òa

moduleid
moduleidָģ¿eID£¬¿ÉÔÚºǫģ¿e¹ÜÀiÀi²eѯ¡£¶ÔÓÚÖ±½Óµ÷ÓÃÄ£¿eµÄÊý¾Ý£¬ÉeÖÃÕýÈ*µÄÄ£¿eIDºo£¬½«²»ÐeÒª´«µÝtable²ÎÊý£¬ÏµÍ³»a×Ô¶¯»ñÈ¡¡£
ÀýÈç´«µÝmoduleid=5£¬ÏµÍ³½«Ê¶±ðΪµ÷Óù(C)Ó¦ÐÅÏ¢£¬×Ô¶¯ÉeÖÃtable²ÎÊýΪsell

table
tableÖ¸±iÃu£¬¿ÉÔÚºǫÊý¾Ý¿aά»¤Ài²eѯ¡£¶ÔÓÚDestoonϵͳ±i£¬²»ÐeÒª¼Ó±iµÄǰ׺£»¶ÔÓÚÇDestoonϵͳ±i£¬ÐeÒªÌiдÍeÕuµÄ±iÃu£¬ÇÒ´«µÝprefix²ÎÊý
ÀýÈç¶ÔÓÚDestoonϵͳ±i£¬´«µÝtable=sell£¬Èç¹u±iǰ׺Ϊdestoon_£¬ÏµÍ³½«Ê¶±ð±iÃuΪ destoon_sell
¶ÔÓÚ
ÇDestoonϵͳ±i£¬´«µÝtable=tbabc&prefix;=»oÕßtable=abc&prefix;=tb£¬ÏµÍ³½«Ê¶±ð±iÃuΪ tb_abc

fields
fieldsÖ¸²eѯµÄ×ֶΣ¬Ä¬ÈÏΪ*¡£¿ÉÒÔ´«µÝÀýÈç fields=title,addtime£¬µ«ÊÇÒ»°aÇe¿oÏÂÎÞÐe´«µÝ£¬Destoon¶ÀÓеıeÇ(C)»º´ae»uÖÆ»a×Ô¶¯»º´ae²eѯ½a¹u£¬²»±Øµ£ÐÄЧÂÊÎÊÌa¡£

condition
conditionÖ¸²eѯµÄÌo¼þ£¬Èç¹u²»´«µÝ£¬ÔoΪ1£¬´u±iÈÎÒaÌo¼þµÄÊý¾Ý(´ËÏiÐeÁ˽aSQLÓi¨)¡£DestoonËuÓÐÄ£¿e×ñѭͳһ±e×¼¿ª¢£¬ËuÒԺܶaÌo¼þÊÇͨÓõġ£
ÀýÈç status=3±iʾÕý³£Í¨¹ýµÄÐÅÏ¢¡¢status=3 and level=1±iʾ¼¶±ðΪ1µÄÐÅÏ¢¡¢status=3 and thumb<>¡±±iʾÓбeÌaͼƬµÄÐÅÏ¢µÈ¡£

order
orderÖ¸Êý¾ÝµÄÅÅÐo½¨(´ËÏiÐeÁ˽aSQLÓi*¨)¡£
ÀýÈçorder=addtime desc±iʾ°´Ìi¼Óʱ¼a½µÐoÅÅÁС¢order=itemid desc±iʾ°´itemid½µÐoÅÅÁС¢order=rand()±iʾËae»uÊý¾ÝµÈ¡£

pagesize
pagesizeÖ¸µ÷ÓÃÊý¾ÝµÄÊýÁ¿£¬Èç¹u²»´«µÝ£¬Ä¬ÈÏΪ10¡£

template
templateÖ¸Ö¸¶¨µÄ±eÇ(C)Ä£°a£¬Èç¹u²»´«µÝ£¬Ä¬ÈÏΪlist£¬Î»ÓÚÄ£°aĿ¼/tag/list.htm£¬Èç¹u´«µÝΪnull£¬±iʾ²»Ó¦ÓñeÇ(C)Ä£°a¡£²Î¼uÉÏÊoÊý¾ÝÏÔʾ¹ý³Ì¡£
ÆaËu³£¼uÓÃ*¨¾ÙÀý

¶a±iÁªºÏ²eѯ
ÀýÈç²eѯ»aÔ±ÃuΪdestoonµÄ»aÔ±ºÍ¹«Ë¾×ÊÁÏ£¬¿ÉÒÔʹÓãº


    {tag(¡°table=destoon_member m,destoon_company c&prefix;=¡±&condition;=m.userid=c.userid and m.username='destoon'&template;=list-com¡±)}

destoon_memberºÍdestoon_companyÊDZiµÄʵ¼ÊÃu³Æ(°uº¬±iǰ׺)£¬prefix=¡±±iʾϵͳ²»ÔÙ×Ô¶¯ÔÚ±iÃuÇ°¼Óǰ׺

¿ØÖƱeÌa³¤¶È
ÔÚ±eÇ(C)Ài´«µÝlength²ÎÊý£¬ÀýÈç&length;=20±iʾ20¸o×Öu³¤¶È(Ò»¸oºº×ÖÕ¼2¸o×Öu)£¬Ò»°aÇe¿o½¨ÒeÓÃcssÒþ²Ø¶aÓa×Öu(¶¨ÒaheightºÍoverflow:hidden)
´«µÝlength²ÎÊý£¬ÏµÍ³½o¶Ôtitle×Ö¶Î×Ô¶¯½ØÈ¡£¬Èç¹uÐeÒª½ØÈ¡ÆaËu×ֶΣ¬¿ÉÓÃdsubstrº¯Êý
ÀýÈç {dsubstr($t[company], 20, ¡®¡­')} ±iʾ½ØÈ¡company×Ö¶ÎΪ20¸o×Ö
u£¬½ØÈ¡ºo£¬½aβ×*¼Ó¡­

ÉeÖÃÈÕÆÚÏÔʾ¸ñʽ
¿ÉÒÔÔÚ±eÇ(C)Ài´«µÝdatetype²ÎÊý£º
1 ±iʾ Äe£»
2 ±iʾ ÔÂ-ÈÕ£»
3 ±iʾ Äe-ÔÂ-ÈÕ£»
4 ±iʾ ÔÂ-ÈÕ Ê±:Ö£»
5 ±iʾ Äe-ÔÂ-ÈÕ Ê±:
Ö£»
6 ±iʾ Äe-ÔÂ-ÈÕ Ê±:*Ö:Ãe
Ò²¿ÉÒÔÔÚÄ£°aÀiÖ±½ÓʹÓÃdateº¯Êý£¬ÀýÈç{date(¡®Y-m-d', $t[addtime])} ±iʾ½«Ê±¼aת»»Îª Äe-ÔÂ-ÈÕ ¸ñʽ

*µ÷ÓÃijһÖÀaµÄÐÅÏ¢
*ÔÚ±eÇ(C)Ài´«µÝcatid²ÎÊý£¬ÀýÈç&catid;=5±iʾµ÷ÓÃÖÀaIDΪ5µÄËuÓÐÐÅÏ¢¡£
Èç¹uµ÷Óöa¸oÖÀa£¬ÓöººÅÖ¸oÖÀaID£¬ÀýÈç &catid;=5,6,7±iʾµ÷ÓÃÖÀaIDΪ5¡¢6¡¢7µÄËuÓÐÐÅÏ¢¡£
ÖÀaµ÷ÓÃĬÈÏ°uº¬×ÓÖÀaµÄÐÅÏ¢£¬Èç¹u²»ÐeÒª°uº¬×ÓÖÀa£¬¿ÉÉeÖÃ&child;=0²ÎÊý¡£
ÀýÈç&catid;=5&child;=0±iʾֻµ÷ÓÃ
ÖÀaIDΪ5µÄÐÅÏ¢£¬²»°uÀ¨×Ó*ÖÀaµÄÐÅÏ¢¡£

µ÷ÓÃijһµØÇøµÄÐÅÏ¢
µ÷ÓõØÇøÐÅÏ¢ºÍÉÏÊoµ÷ÓÃÖÀaÐÅÏ¢µÄ½*¨ÍeÈ«Ïaͬ£¬½«ÆaÖеÄcatid»»Îªareaid¼´¿É¡£

*ÏÔʾÐÅÏ¢ËuÔÚÖÀa
**


    <a href=¡±{$MODULE[$moduleid][linkurl]}{$CATEGORY[$t[catid]][linkurl]}¡±>{$CATEGORY[$t[catid]][catname]}</a>

¿ØÖÆÁÐÊý
´ËÏi³£ÓÃÓÚͼƬµÄ²¼¾Ö£¬¿ÉʹÓÃcols²ÎÊý¡£
ÀýÈçµ÷ÓÃ12ÕÅͼƬ£¬Ò»ÐÐÏÔʾ4¸o£¬¹²3ÐУ¬Ôo´«µÝ&pagesize;=12&cols;=4
Ö§³Öcols²ÎÊýµÄ±eÇ(C)Ä£°aÏÞthumb-table.htmºÍlist-table.htm
ÆaÖУ¬thumb-table.htmÏÔʾͼƬÁбi£¬list-table.htmÏÔʾÎÄ×ÖÁбi
Èç¹uн¨Ö§³ÖcolsµÄ±eÇ(C)Ä£°a»oÖ±½ÓÑ­»$tags£¬¿É²Î¿¼ÒÔÉÏÁ½¸oÄ£°aµÄд¨
ÉÏÊoЧ¹u¿ÉÒÔÒ²¿ÉÒÔͨ¹ýCSSʵÏÖ£¬ÎÞÐeʹÓñi¸ñ£¬Çe×ÔÐÐÊeд

ÏÔʾÎÄÕµļo½e
ʹÓÃ{$t[introduce]}±aÁ¿£¬Èç¹uÒª½ØÈ¡×ÖÊý£¬ÀýÈç80×Ö*u£¬¿ÉʹÓÃ{dsubstr($t[introduce], 80, ¡®¡­')}

º¯ÊýÔ­ÐÍ
tag($parameter, $expires = 0)
$parameter ±iʾ´«µÝ¸øtagº¯ÊýµÄ×Ö*u´®£¬ÏµÍ³×Ô¶¯½«Æaת»»Îª¶a¸o±aÁ¿
ÀýÈç´«µÝ table=destoon&pagesize;=10£¬ÏµÍ³Ïaµ±Óڵõ½$table = ¡®destoon'£»$pagesize = 10£»Á½¸o±aÁ¿
$expires ±iʾ»º´ae¹ýÆÚʱ¼a

0 »º´ae$expiresÃe£»0 ¨C ϵͳĬÈÏʱ¼a£»-1 ¨C ²»»º´ae£»-2 ¨C »º´aeSQL£»Ò»°aÇe¿o±£³ÖĬÈϼ´¿É¡£

³£Á¿
{DT_SKIN}
ϵͳç¸ñÍøÖ¡£
{DT_PATH}
ÍøÕ¾Ê×Ò³ÍøÖ¡£

±aÁ¿
$tags
ÒÔÊý×eÀaÐͱ£´ae±eÇ(C)µ÷ÓõÄÊý¾Ý£¬¿Éͨ¹ýloopÓi
¨±eÀuÏÔʾ¡£
$pages
±£´aeÊý¾ÝÖÒ³´uÂe£¬½oÔÚµ÷ÓÃÁËÖҳʱÓÐЧ¡£
$MODULE[5][name]
IDΪ5µÄÄ£¿eÃu³Æ¡£
$MODULE[5][linkurl]
IDΪ5µÄÄ£¿eÍøÖ¡£
$CATEGORY[5][catname]
IDΪ5µÄ
ÖÀaÃu³Æ(½o±aÁ¿$CATEGORY´aeÔÚʱÓÐЧ)¡£
$CATEGORY[5][linkurl]
IDΪ5µÄÖÀaÍøÖ(½o±aÁ¿$CATEGORY´aeÔÚʱÓÐЧ)¡£

³£ÓÃ×Ö¶Î
title ±eÌa£» linkurl Á´½Ó£» catid ÖÀaID£» introduce ¼o½e£» addtime Ìi¼Óʱ¼a£» ³£Óú¯Êý dsubstr($string, $length, $suffix = ¡±)
½«×Ö
u´®$string½ØȡΪ$length³¤,β²¿×*¼Ó$suffix(ÀýÈç..)
date($format, $timestamp)
½«Ê±¼a´Á$timestampת»¯Îª$format(ÀýÈçY-m-d)¸ñʽ

±eÇ(C)Ä£°a
Ä£°a±£´aeÓÚ./template/default/tag/Ŀ¼£»
½¨Òe²»ÒªÉ¾³ý»oÕßÐÞ¸Ä×Ô´øµÄÄ£°a£¬ÍƼoÔÚ×Ô´øÄ£°a»u´¡ÉÏн¨Ä£°a²¢Ó¦Óá£

1.±eÇ(C)¸ñʽµÄ´oÖÂ˵Ã÷


    <!¨C{tag(¡°moduleid=9&table;=article_9&length;=40&condition;=status=3&pagesize;=10&datetype;=2&order;=addtime desc&target;=_blank¡±)}¨C>

moduleid=9ÊÇ×ÊѶģ¿eID, Ä£¿eIDȥģ¿e¹ÜÀi²e¿´£»
articleÊÇ×ÊѶģ¿eĿ¼Ãu£»
&length;=40ÊDZeÇ(C)½ØÈ¡×ÖÊý
&pagesize;=10Êǵ÷ÓÃÌoÊý
&datetype;=2ÊÇÏÔʾʱ¼aÌi¼Óʱ¼a

2.µ÷ÓÃ×iмÓÈeÆoÒµ


    <!¨C{tag(¡°moduleid=4&table;=company&condition;=groupid>4&pagesize;=10&order;=userid desc&template;=list-com¡±)}¨C>

3.ÈçºÎµ÷ÓÃÆaÖÐÒ»¸oÆoÒµ»aÔ±µÄ¹(C)ÇoÐÅÏ¢¼°×ÊѶ
ÔÚcondition=Ài¼Ó and username='xxx'? xxxΪ»aÔ±µÇ¼Ãu

4.ÈçºÎµ÷Óà ¹(C)Ó¦ Ço¹º ²uÆ ÏÂµÄ Ä³¸oÖÀa
µ÷ÓÃ*ÖÀaϵÄÐÅÏ¢¿ÉÒÔÉeÖà &catid;=ÐÐÒµid&child;=1 child=1±iʾͬʱµ÷ÓÃÏÂÊoµÄÐÐÒµ

5.µ÷Óöþ¼¶À¸Ä¿ÐÅÏ¢Áбi


    <!¨C{tag(¡°moduleid=$moduleid&table;=article_$moduleid&catid;=$catid&child;=1
    &condition;=status=3&order;=¡±.$MOD[order].¡±&pagesize;=6&datetype;=2&target;=_blank¡±)}¨C>

Èç¹uÄaÊÇÔÚÎÄÕÂÄ£¿eÀiµ÷Óà ¿ÉÒÔÓÃÉÏÃaeµÄ´uÂe $catid ¸ÄΪÄaÒªµ÷ÓõÄÀ¸Ä¿id¼´¿É
Èç¹uÐeҪͬʱµ÷ÓÃÀ¸Ä¿ÏµÄÐÅÏ¢ child=1¼´¿É ñÔo child=0
Èç¹uÊÇÔÚÍøÕ¾ÆaËuµØ
½µ÷Ó㬿ÉÒÔÓÃÏÂÃaeµÄ´uÂe£º


    <!¨C{tag(¡°moduleid=9&table;=article_9&catid;=$catid&child;=1&condition;=status=3&order;=addtime desc&pagesize;=6&datetype;=2&target;=_blank¡±)}¨C>

×¢ÒamoduleidµÄÖµÒªÓeÄaµ÷ÓõÄÄ£¿eid±£³ÖÒ»ÖÂ
²¹³a£º
ÏÂÃaeÕa¸oÔÚÊ×Ò³µ÷Óóɹ¦


    <!¨C{tag(¡°moduleid=9&table;=article_9&catid;=$catid&child;=1&condition;=status=3&order;=addtime desc&pagesize;=6&datetype;=2&target;=_blank¡±)}¨C>

µ«ÊÇÎÒÏeÒª×ÊѶҳÄÚ²¿µÄÄ£°aeÁбi£¬Ò²¾ÍÊÇÿÌoÖ»ÏÔʾ22¸o×Ö¡£

6.Ê×Ò³×ÊѶÀ¸Ä¿ÕaÀiÔoôµ÷ÓÃ
¡°9¡±ÎªÄaÄ£¿eµÄID


    {php $C = get_maincat(0, cache_read(¡®category-9.php'));}
    {loop $C $k $v}
    <a href=¡±{$MODULE[9][linkurl]}{$v[linkurl]}¡±>{$v[catname]}</a>
    {/loop}

7.¹«Ë¾Áбi ²»ÄÜ¿ØÖÆ×ÖÊý£¡£¡
Äa¿ÉÒÔÖ±½ÓÐÞ¸Ä list-com.htm
{$t[company]} Ϊ {dsubstr($t[company], $length)}

8.TAG³£ÓñeÇ(C)
{$CATEGORY[$t[catid]]["catname"]} ËuÊoÀ¸Ä¿Ãu³Æ£» {timetodate($t["addtime"], $datetype)}? *¢²¼Ê±¼a

9.ÆaËu
Äa¿ÉÒÔͨ¹ý&template;= À´Ö¸¶¨±eÇ(C)Ä£°ae
Èç¹uûÓÃÕa¸o²ÎÊý ĬÈÏÊÇlist
λÓÚÄ£°aeĿ¼tagĿ¼
×ÊѶ ¼¶±ðlevel 1¼¶Îª ÍƼoÎÄÕ £»2¼¶Îª »ÃµÆͼƬ£»3¼¶Îª ÍƼoͼÎÄ£»4¼¶Îª ÍÌoÎÄÕ£»5¼¶Îª ÍÌoÏa¹Ø

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
文件下载
贪吃蛇
获取IMEI
双位运算符
发送邮件
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
提取后缀名
年的日历图
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例