{"id":766,"date":"2013-06-08T15:06:48","date_gmt":"2013-06-08T07:06:48","guid":{"rendered":"http:\/\/www.xiaojia.info\/?p=766"},"modified":"2013-06-08T15:06:56","modified_gmt":"2013-06-08T07:06:56","slug":"assign_dynamictmp","status":"publish","type":"post","link":"https:\/\/www.luja.cc\/?p=766","title":{"rendered":"assign_dynamic($tmp)\u51fd\u6570\u7684\u4f7f\u7528"},"content":{"rendered":"<p>\u8fd1\u65e5\u9700\u8981\u5728ecshop\u4e2d\u65b0\u589e\u4e00\u4e2aphp\u9875\u9762\uff0c\u91cc\u9762\u6d89\u53ca\u5230\u4e00\u4e9b\u52a8\u6001\u6587\u7ae0\u5185\u5bb9\u7684\u8c03\u7528\u3002<br \/>\n<!--more--><br \/>\n \u56e0\u4e3a\u4e4b\u524d\u6ca1\u6709\u505a\u8fc7\u6240\u4ee5\u5c31\u5bf9\u7167index.php\u6765\u5199\u4e86\u3002\u9996\u5148\u81ea\u5df1\u65b0\u589e\u4e86\u4e00\u4e2adwt\u6587\u4ef6\uff0c\u5728\u91cc\u9762\u8bbe\u7f6e\u4e00\u4e2a\u53ef\u7f16\u8f91\u533a\u57df\u3002\u5728admin\/includes \/lib_template.php\u91cc\u9762\uff0c\u5728$template_files\u8fd9\u4e2a\u6570\u7ec4\u4e2d\u6dfb\u52a0\u4e86\u4e00\u4e2a\u53ef\u4ee5\u8bbe\u7f6e\u5185\u5bb9\u7684\u6a21\u677f,news.dwt, \u5728$page_libs\u8fd9\u4e2a\u6bcf\u4e2a\u6a21\u677f\u5141\u8bb8\u8bbe\u7f6e\u7684\u5e93\u9879\u76ee\u7684\u6570\u7ec4\u91cc\u9762\u6dfb\u52a0\u4e86\u2019news\u2019 => array(<br \/>\n\u2018\/library\/ur_here.lbi\u2019 => 0,<br \/>\n\u2018\/library\/cart.lbi\u2019 => 0,<br \/>\n\u2018\/library\/category_tree.lbi\u2019 => 0,<br \/>\n\u2018\/library\/history.lbi\u2019 => 0,<br \/>\n\u2018\/library\/pages.lbi\u2019 => 0,<br \/>\n\u2018\/library\/exchange_hot.lbi\u2019 => 5,<br \/>\n\u2018\/library\/exchange_list.lbi\u2019 => 0,<br \/>\n),\u7136\u540e\u5728\u540e\u53f0\u201d\u8bbe\u7f6e\u6a21\u677f\u201d\u8fd9\u91cc\uff0c\u5728languages\/zh_cn\/admin\/template.php\u91cc\u9762\u5bf9\u8fd9\u4e2a\u6a21\u677f\u6587\u4ef6\u6dfb\u52a0\u76f8\u5e94\u7684\u8bed\u8a00,$_LANG[&#8216;template_files&#8217;][&#8216;news&#8217;] = \u2018\u65b0\u95fb\u9875\u9762\u2019;<br \/>\n\u7ecf\u8fc7\u4ee5\u4e0a\u8fd9\u6837\u8bbe\u7f6e\u4e4b\u540e\uff0c\u5728\u201d\u540e\u53f0\u6a21\u677f\u201d\u2014\u201c\u8bbe\u7f6e\u6a21\u677f\u201d\u8fd9\u91cc\u7684\u4e0b\u62c9\u6846\u8fd9\u91cc\u5c31\u53ef\u4ee5\u770b\u5230\u8fd9\u4e2a\u65b0\u6dfb\u52a0\u7684\u6a21\u677f\u4e86\u3002\u6d4b\u8bd5\u53d1\u73b0\uff0c\u5982\u679c\u60f3\u5728\u8fd9\u4e2a\u9875\u9762\u5185\u663e\u793a\u4e00\u4e9b\u52a8\u6001\u7684\u5185\u5bb9\u3002\u5c31\u5fc5\u987b\u52a0\u4e0a:assign_dynamic(\u2018news\u2019).<br \/>\nassign_dynamic($tmp)\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u662f\u6d3b\u7684\u6307\u5b9a\u9875\u9762\u7684\u52a8\u6001\u5185\u5bb9\uff0c\u52a8\u6001\u5904\u7406\u4e00\u4e9b\u5c40\u90e8\u4fe1\u606f\u66f4\u65b0\u800c\u4e0d\u88ab\u7f13\u5b58\u7684\u673a\u5236\uff0c\u5176\u4e2d$tmp\u4e3a\u6a21\u677f\u540d\u79f0\u3002<br \/>\n$sql = \u2018SELECT id, number, type FROM \u2018 . $GLOBALS[&#8216;ecs&#8217;]->table(\u2018template\u2019) .  \u201d WHERE filename = \u2018$tmp\u2019 AND type > 0 AND remarks =\u201d AND theme=\u2019\u201d . $GLOBALS[&#8216;_CFG&#8217;][&#8216;template&#8217;] . \u201c\u2018\u201d;$res = $GLOBALS[&#8216;db&#8217;]->getAll($sql) \u5176\u4e2d\u5b57\u6bb5number\u63a7\u5236\u6bcf\u6b21\u663e\u793a\u591a\u5c11\u4e2a\u503c\uff0c\u800c\u5b57\u6bb5type\u5219\u63a7\u5236\u5c5e\u4e8e\u54ea\u4e2a\u52a8\u6001\u9879,0\u4e3a\u56fa\u5b9a\u9879,1\u4e3a\u5206\u7c7b\u4e0b\u7684\u5546\u54c1\uff0c2\u4e3a\u54c1\u724c\u4e0b\u7684\u5546\u54c1\uff0c3\u4e3a\u6587\u7ae0\u5217\u8868,4\u4e3a\u5e7f\u544a\u4f4d.<br \/>\n\u901a\u8fc7\u8fc7\u8fd9\u4e2a\u6761\u4ef6\uff0c\u5206\u522b\u6267\u884c\u76f8\u5e94\u7684\u51fd\u6570\uff0c\u4f8b\u5982\u7528$GLOBALS[\u2018smarty\u2019]->assign(\u2018goods_cat_\u2019.$row[\u2018id\u2019],assign_cat_goods($row[\u2018id\u2019],$row[\u2018number\u2019])); \u7ed9\u4e0d\u540c\u7684\u6a21\u5757\u8d4b\u503c\u3002\u6bd4\u5982\u5728\u5206\u7c7b\uff0c\u5c31\u8c03\u7528ssign_cat_goods()\u51fd\u6570\uff0c\u4f20\u9012\u7ed9\u6a21\u677f\u53c2\u6570\u2019goods_cat_\u2019 . $row[&#8216;id&#8217;].<br \/>\n\u5728\u6700\u540eecshop smarty\u5c06\u4f1a\u8c03\u7528dyna_libs_replace()\u51fd\u6570\uff0c\u5bf9\u4e0d\u540c\u7684\u6a21\u5757\uff0c\u7ed9\u4e88template,\u901a\u8fc7\u4f8b\u5982  $str = \u2018{assign var=\u201dcat_goods\u201d value=$cat_goods_\u2019 .$row[&#8216;id&#8217;]. \u2018}{assign var=\u201dgoods_cat\u201d value=$goods_cat_\u2019 .$row[&#8216;id&#8217;]. \u2018}\u2019;\u65b9\u5f0f\u4f20\u9012\u3002\u6240\u4ee5\u5728\u6a21\u677f\u91cc\u9762\uff0c\u53ef\u4ee5\u770b\u5230$cat_goods.\u5c31\u662f\u8fd9\u4e48\u6765\u7684\u3002<br \/>\n\u6240\u6709\u7684\u8c03\u7528\uff0c\u5c31\u662f\u8fd9\u4e2a\u673a\u5236\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd1\u65e5\u9700\u8981\u5728ecshop\u4e2d\u65b0\u589e\u4e00\u4e2aphp\u9875\u9762\uff0c\u91cc\u9762\u6d89\u53ca\u5230\u4e00\u4e9b\u52a8\u6001\u6587\u7ae0\u5185\u5bb9\u7684\u8c03\u7528\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[75],"tags":[148,180],"_links":{"self":[{"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/posts\/766"}],"collection":[{"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.luja.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=766"}],"version-history":[{"count":2,"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/posts\/766\/revisions"}],"predecessor-version":[{"id":768,"href":"https:\/\/www.luja.cc\/index.php?rest_route=\/wp\/v2\/posts\/766\/revisions\/768"}],"wp:attachment":[{"href":"https:\/\/www.luja.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=766"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.luja.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=766"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.luja.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=766"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}