{"id":1148,"date":"2009-11-07T22:55:45","date_gmt":"2009-11-07T14:55:45","guid":{"rendered":"http:\/\/nan.im\/blog\/?p=1148"},"modified":"2009-11-07T22:55:45","modified_gmt":"2009-11-07T14:55:45","slug":"%e3%80%90drupal%e3%80%91%e4%b8%ba-theme_box-%e6%b7%bb%e5%8a%a0%e4%b8%aa%e6%80%a7-class-%e4%bb%a5%e6%96%b9%e4%be%bf%e5%ae%9a%e5%88%b6-css-%e6%a0%b7%e5%bc%8f%e5%a4%96%e8%a7%82","status":"publish","type":"post","link":"http:\/\/nan.im\/blog\/1148","title":{"rendered":"\u3010Drupal\u3011\u4e3a theme_box \u6dfb\u52a0\u4e2a\u6027 class \u4ee5\u65b9\u4fbf\u5b9a\u5236 CSS \u6837\u5f0f\u5916\u89c2"},"content":{"rendered":"<p>\u5728 Drupal \u4e2d\u6709\u5f88\u591a\u9884\u5b9a\u4e49\u7684 theme \u51fd\u6570\uff08\u5728 theme.inc \u4e2d\uff09\u800c\u591a\u6570\u4e3b\u9898\u51fd\u6570\u5728\u6e32\u67d3\u65f6\u5e76\u6ca1\u6709\u8fc7\u591a\u7684\u8003\u8651\u524d\u7aef\u7684 CSS \u6837\u5f0f\u5b9a\u4e49\u53ca\u5448\u73b0\u95ee\u9898\uff0c\u5176\u4e2d theme_box \u5c31\u662f\u5176\u4e2d\u4e4b\u4e00\uff0c\u5728 Drupal \u4e2d\u9ed8\u8ba4\u7684\u201c\u8bc4\u8bba\u8868\u5355\u201d\u53ca\u201c\u641c\u7d22\u7ed3\u679c\u201d\u5c31\u4f7f\u7528 theme(&#8216;box&#8217;) \u51fd\u6570\u6e32\u67d3\uff0c\u4f46\u5982\u679c\u60f3\u533a\u5206\u5bf9\u5f85\uff0c\u5206\u522b\u5b9a\u4e49\u4e0d\u540c\u7684 CSS \u6837\u5f0f\u4f1a\u53d1\u73b0\u76f8\u5f53\u56f0\u96be\uff0c\u8fd9\u91cc\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u7684\u8986\u5199\u4e3b\u9898\u51fd\u6570\u7684\u65b9\u6cd5\u6765\u4e3a theme_box \u6dfb\u52a0\u989d\u5916\u7684 class \u4ee5\u65b9\u4fbf\u524d\u7aef\u9644\u52a0\u4e2a\u6027\u7684 CSS \u6837\u5f0f\u3002<!--more--><\/p>\n<p>\u505a Drupal \u5f00\u53d1\u6700\u57fa\u672c\u7684\u539f\u5219\u5c31\u662f\u907f\u514d\u4fee\u6539\u6838\u5fc3\u4ee3\u7801\uff0c\u6240\u4ee5\u6211\u5728\u4e3b\u9898\u6a21\u677f\u7684 template.php \u6587\u4ef6\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre lang=\"php\" line=\"1\">\nfunction anyLiv_box( $title, $content, $region = 'main' ){\n\t$output  = '<div class=\"box box-'.substr(md5($title),-4).'\">';\n\t$output .= '<h2 class=\"head\">'. $title .'<\/h2>';\n\t$output .= '<div class=\"body\">'. $content .'<\/div>';\n\t$output .= '<\/div>';\n\treturn $output;\n}\n<\/pre>\n<p>\u5176\u4e2d\u7684 anyLiv \u6362\u6210\u4f60\u7684\u4e3b\u9898\u540d\u79f0\u3002\u8fd9\u91cc\u9664\u7ed9\u6574\u4e2a box \u5916\u9762\u6dfb\u52a0\u4e00\u4e2a div \u4ee5\u5916\u8fd8\u989d\u5916\u6dfb\u52a0\u4e86 class \u5176\u4e2d box \u53ef\u7528\u6765\u5b9a\u4e49 box \u7684\u6574\u4f53\u5916\u89c2\uff0c\u800c\u540e\u9762\u6839\u636e $title md5 \u4e4b\u540e\u751f\u6210\u7684\u56db\u4e2a\u5b57\u7b26\u7528\u6765\u5b9a\u4e49\u4e2a\u522b box \u7684\u5916\u89c2\uff0c\u56e0\u4e3a\u901a\u5e38 box \u7684 title \u80fd\u51b3\u5b9a\u8fd9\u4e2a box \u7684\u529f\u80fd\u3002<\/p>\n<p>\u505a\u5b8c\u4e0a\u8ff0\u5de5\u4f5c\u67e5\u770b\u4ee3\u7801\u4f1a\u53d1\u73b0\u8bc4\u8bba\u8868\u5355\u5373\u201c\u53d1\u8868\u65b0\u8bc4\u8bba\u201d\u5df2\u7ecf\u5305\u542b\u4e86 box box-812b \u4e24\u4e2a class \u800c\u4f7f\u7528 theme_box \u6e32\u67d3\u7684\u201c\u641c\u7d22\u7ed3\u679c\u201d\u5df2\u7ecf\u5305\u542b\u4e86 box box-1f1b \u4e24\u4e2a class \u8fd9\u6837\u5c31\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u5206\u522b\u4f7f\u7528 CSS \u4e3a\u201c\u53d1\u8868\u65b0\u8bc4\u8bba\u201d\u548c\u201c\u641c\u7d22\u7ed3\u679c\u201d\u5b9a\u5236\u5916\u89c2\u4e86\u3002<\/p>\n<p>\u7f3a\u70b9\uff1a\u867d\u7136\u6ca1\u6709\u6d89\u53ca\u4fee\u6539\u6838\u5fc3\u4ee3\u7801\uff0c\u5e76\u4e14\u6682\u65f6\u89e3\u51b3\u4e86\u95ee\u9898\uff0c\u4f46\u8fd9\u79cd\u65b9\u6cd5\u5e76\u975e\u63a8\u8350\u7684\u505a\u6cd5\uff0c\u6bd5\u7adf MD5 \u8fd0\u7b97\u9700\u8981\u6d88\u8017\u670d\u52a1\u5668\u8d44\u6e90\uff0c\u5f53\u7136\u4f7f\u7528\u5176\u4ed6\u8fd0\u7b97\u90fd\u662f\u53ef\u4ee5\u7684\u5982 CRC32 \u7b49\u7b49\uff0c\u53ea\u8981\u8f93\u51fa\u7684\u7ed3\u679c\u7b26\u5408 class \u7684\u547d\u540d\u89c4\u5219\u5373\u53ef\u3002<\/p>\n<p>\u62d3\u5c55\uff1a\u5176\u5b9e\u8fd9\u79cd\u65b9\u6cd5\u8fd8\u53ef\u4ee5\u7528\u5728 theme_links \u51fd\u6570\u4e0a\u4e3a\u6bcf\u4e00\u4e2a\u94fe\u63a5\u5b9a\u4e49\u5355\u72ec\u7684 class \u8fd9\u6837\u53ef\u4ee5\u65b9\u4fbf\u4e3a\u6bcf\u4e2a\u94fe\u63a5\u5b9a\u4e49\u4e0d\u540c\u7684 CSS \u80cc\u666f\u56fe\u6807\u7b49\u7b49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Drupal \u4e2d\u6709\u5f88\u591a\u9884\u5b9a\u4e49\u7684 theme \u51fd\u6570\uff08\u5728 theme.inc \u4e2d\uff09\u800c\u591a\u6570\u4e3b\u9898\u51fd\u6570\u5728\u6e32\u67d3\u65f6\u5e76\u6ca1\u6709 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[20,24,31,120,76],"class_list":["post-1148","post","type-post","status-publish","format-standard","hentry","category-tech","tag-code","tag-develop","tag-drupal","tag-php","tag-theme"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts\/1148","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/comments?post=1148"}],"version-history":[{"count":0,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/posts\/1148\/revisions"}],"wp:attachment":[{"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/media?parent=1148"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/categories?post=1148"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nan.im\/blog\/wp-json\/wp\/v2\/tags?post=1148"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}