×ðÁú¿­Ê±

thinkphpµ¼º½À¸ÔõôÅжÏÄ¿½ñÒ³Ãæ

ÔÚ¾ÙÐÐÍøÕ¾¿ª·¢Ê±£¬¾­³£ÐèÒªÌí¼Óµ¼º½À¸À´Àû±ãÓû§»á¼ûÍøÕ¾µÄ²î±ðÒ³Ãæ¡£¶øÔÚʹÓÃphp¿ò¼Üthinkphp¾ÙÐпª·¢Ê±£¬ÔõÑùÅжÏÄ¿½ñÒ³ÃæÊôÓÚÄÄÒ»¸öµ¼º½À¸ÄØ£¿±¾ÎĽ«Ïò¸÷ÈËÏÈÈÝthinkphpµ¼º½À¸µÄʵÏÖÒªÁìÒÔ¼°ÔõÑùÅжÏÄ¿½ñÒ³Ãæ¡£

Ò»¡¢ThinkPHPµ¼º½À¸ÊµÏÖÒªÁì

ÔÚThinkPHPÖУ¬Í¨³£Ê¹Óù«¹²Ä£°å·½·¨À´ÊµÏÖµ¼º½À¸¡£Ïêϸ°ì·¨ÈçÏ£º

1¡¢Ê×ÏȽ¨ÉèÒ»¸ö¹«¹²Ä£°åÎļþ£¬ÀýÈçheader.html£¬ÓÃÓÚ´æ´¢ÍøÕ¾µÄµ¼º½À¸´úÂë¡£ÔÚ¸ÃÎļþÖУ¬¿ÉÒÔƾ֤ÐèÇó×Ô½ç˵µ¼º½À¸µÄÑùʽºÍ½á¹¹¡£

2¡¢ÔÚ¸÷¸ö×ÓÒ³ÃæÖÐÒýÓøù«¹²Ä£°åÎļþ£¬½«µ¼º½À¸´úÂëǶÈëµ½×ÓÒ³ÃæÖС£ÔÚThinkPHP¿ò¼ÜÖУ¬Ê¹ÓÃÒÔÏ´úÂëÒýÓù«¹²Ä£°åÎļþ£º

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

<?php include(THEME_PATH . 'header.html'); ?>

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬THEME_PATHÊÇÓû§×Ô½ç˵µÄÖ÷Ìâ·¾¶¡£

3¡¢ÔÚ¹«¹²Ä£°åÎļþÖУ¬ÐèҪʹÓÃPHP´úÂëÀ´ÅжÏÄ¿½ñÒ³ÃæËùÊôµÄµ¼º½À¸¡£Í¨³£Ê¹ÓÃ$_SERVER[‘REQUEST_URI’]±äÁ¿À´»ñÈ¡Ä¿½ñÒ³ÃæµÄURLµØµã£¬ÔÙͨ¹ýifÓï¾äÅжÏÄ¿½ñÒ³ÃæËùÊôµÄµ¼º½À¸¡£

ÀýÈ磬ÒÔÏ´úÂë¿ÉÒÔÅжÏÄ¿½ñÒ³ÃæÊÇ·ñÊôÓÚÊ×Ò³µ¼º½À¸£º

<?php if(strpos($_SERVER['REQUEST_URI'], 'index/index') !== false) {?>
    <li class="active"><a href="/index.php/Home/Index/">Ê×Ò³</a></li>
<?php } else { ?>
    <li><a href="/index.php/Home/Index/">Ê×Ò³</a></li>
<?php } ?>

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëÖУ¬strpos()º¯ÊýÓÃÓÚÅжÏÄ¿½ñÒ³ÃæURLµØµãÖÐÊÇ·ñº¬ÓÐ’index/index’×Ö·û´®£¬ÈôÊÇÓУ¬Ôò˵Ã÷Ä¿½ñÒ³ÃæÊôÓÚÊ×Ò³µ¼º½À¸£¬È»ºóͨ¹ýÉèÖÃ

±êÇ©µÄactiveÊôÐÔÀ´¸øÄ¿½ñµ¼º½À¸Ìí¼ÓÑ¡ÖÐ״̬¡£

¶þ¡¢ÅжÏÄ¿½ñÒ³ÃæËùÊôµ¼º½À¸µÄÒªÁì

ÔÚÉÏÒ»²½ÖУ¬ÒѾ­ÏÈÈÝÁËÔõÑùʹÓÃifÓï¾äÅжÏÄ¿½ñÒ³ÃæËùÊôµÄµ¼º½À¸¡£¿ÉÊÇ£¬ÔÚÏÖʵ¿ª·¢ÖУ¬ÕâÖÖÒªÁì¿ÉÄ᷺ܻÆðһЩÎÊÌ⣬ÀýÈ磺ÈôÊÇURLµØµãÖдøÓвÎÊý£¬ÔõÑùÅжÏÄ¿½ñÒ³ÃæËùÊôµÄµ¼º½À¸£¿´Ëʱ£¬¾ÍÐèҪʹÓÃÔ½·¢ÖÇÄܵÄÒªÁìÀ´½â¾öÎÊÌâ¡£

ÔÚThinkPHP¿ò¼ÜÖУ¬¿ÉÒÔͨ¹ý½ç˵µ¼º½À¸Êý×éºÍÅжÏÄ¿½ñ¿ØÖÆÆ÷ºÍ²Ù×÷ÒªÁìÀ´ÊµÏÖÖÇÄÜÅжÏÄ¿½ñÒ³ÃæËùÊôµÄµ¼º½À¸¡£Ïêϸ°ì·¨ÈçÏ£º

1¡¢ÔÚÉèÖÃÎļþÖнç˵µ¼º½À¸Êý×é¡£ÀýÈ磺

//½ç˵µ¼º½À¸Êý×é
'NAV_LIST' => array(
    'Ê×Ò³' => array('Index', 'index'),
    'ÐÂÎÅ' => array('News', 'index'),
    '²úÆ·' => array('Product', 'index'),
    'ÁªÏµ×ðÁú¿­Ê±' => array('Contact', 'index'),
),

µÇ¼ºó¸´ÖÆ

ÒÔÉÏÊý×éÖУ¬¼üÌåÏÖµ¼º½À¸µÄÃû³Æ£¬ÖµÊÇÒ»¸öÊý×飬°üÀ¨¿ØÖÆÆ÷ºÍ²Ù×÷ÒªÁìµÄÃû³Æ¡£

2¡¢ÔÚ¹«¹²Ä£°åÎļþÖУ¬Ê¹ÓÃforeachÑ­»·±éÀúµ¼º½À¸Êý×飬²¢Ê¹ÓÃifÓï¾äÅжÏÄ¿½ñ¿ØÖÆÆ÷ºÍ²Ù×÷ÒªÁìÊÇ·ñÓëµ¼º½À¸Êý×éÖеÄÖµÏàͬ¡£ÈôÊÇÏàͬ£¬ÔòÌí¼ÓactiveÊôÐÔ¸ø¸Ãµ¼º½À¸£¬ÌåÏÖÄ¿½ñÒ³ÃæËùÊô¡£

ÀýÈ磬ÒÔÏ´úÂë¿ÉÒÔÖÇÄÜÅжÏÄ¿½ñÒ³ÃæËùÊôµÄµ¼º½À¸£º

<?php foreach(C('NAV_LIST') as $key=>$vo){ ?>
    <?php $active = strtolower(CONTROLLER_NAME) == strtolower($vo[0]) && strtolower(ACTION_NAME) == strtolower($vo[1]) ? 'class=active' : ''; ?>
    <li <?php echo $active;?>><a href="<?php echo U($vo[0].'/'.$vo[1]);?>"><?php echo $key;?></a></li>
<?php } ?>

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂëÖУ¬Ê¹ÓÃforeachÑ­»·±éÀúµ¼º½À¸Êý×顣Ȼºó£¬Ê¹ÓÃifÓï¾äÅжÏÄ¿½ñ¿ØÖÆÆ÷ºÍ²Ù×÷ÒªÁìÊÇ·ñÓëµ¼º½À¸Êý×éÖеÄÖµÏàͬ¡£ÈôÊÇÏàͬ£¬Ôò¸ø

±êÇ©Ìí¼ÓactiveÊôÐÔ£¬ÌåÏÖÄ¿½ñÒ³ÃæËùÊô¡£ÆäÖУ¬strtolower()º¯ÊýÓÃÓÚ½«´óд×Öĸת»»ÎªÐ¡Ð´×Öĸ£¬×èÖ¹ÓÉÓÚ¾ÞϸдÎÊÌâµ¼ÖÂÅжϹýʧ¡£

×ÛÉÏ£¬ÎÞÂÛÊÇʹÓÃifÓï¾äÅжÏÄ¿½ñÒ³ÃæÊôÓÚÄÄÒ»¸öµ¼º½À¸£¬ÕÕ¾ÉʹÓÃÖÇÄÜÅжÏÒªÁ죬¶¼ÐèÒªÀíÇåThinkPHP¿ò¼ÜµÄÏà¹Ø֪ʶ¡£Ï£Íû±¾ÎĵÄÏÈÈÝÄܹ»¶Ô¸÷ÈËÔÚʹÓÃThinkPHP¿ò¼Ü¿ª·¢ÍøվʱÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇthinkphpµ¼º½À¸ÔõôÅжÏÄ¿½ñÒ³ÃæµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿