Widgetizing Your Blog widgetizing您的博客
June 15th, 2007 · by David Bradley 2007年6月15日,大衛布拉德利
If you have already upgraded to Wordpress 2.2, then this post is not for you.如果您已升級到2.2的WordPress ,那麼這個職位是不是你。 But, if you are languishing on an earlier installation and running a theme that does not support widgets, then you may like to check out how to get widgetized.但是,如果您是languishing對先前安裝和運行的一個主題,這並不支持widgets的,那麼您可能想檢查如何獲得widgetized 。 But, first what are widgets?但是,首先是什麼工具? Well, they’re little snippets of code that sit in their own boxes within your sidebar and can be reordered with a simple drag and drop.那麼,他們正在小片斷的代碼,靜坐在自己的箱子在您的工具欄可以重新排序,與一個簡單的拖放。 So, your search box is at the bottom and your Feedburner count at the top but you want them the other way around?所以,您的搜索框是在底部和您的feedburner計數在最上方,但你希望他們其他方式? It’sa lot of cutting and pasting with the standard sidebar in Theme Editor, but if your blog is widgetized all you do is drag the search widget to the top of the stack and the Feedburner block to the bottom.這是大量的切割和粘貼符合標準工具欄在主題編輯器,但如果您的博客是widgetized所有你做的是拖曳搜索窗口組件上方的堆棧和feedburner座至底部。 And save the new settings.並保存新的設置。
The Automattic site has the full skinny on該automattic網站已充分瘦就 widgetizing your site widgetizing您的網站 and provides you with the necessary downloads, so I am not going to repeat their wise words here.為您提供必要的下載,所以我不再重複他們的明智的話在這裡。 But, one aspect of widgetizing the Sciencebase site earlier this year, prior to the release of version 2.2, was that I simply could not eradicate an orphaned bullet point that was appearing at the top of the sidebar with no entry to which is was associated.但是,一個方面widgetizing該sciencebase網站今年早些時候,該標準發布以前, 2.2版,是我根本無法根除孤立的子彈點,這是出現在工具欄頂部沒有進入這是相關。 I messed around with the li and ul tags in the widgets themselves, played with the css in the widgets.php (adding the list-style-type: none; tag to all and sundry to try and delete the little dot). i搞砸左右,與李和UL標籤,在widgets的自己,發揮與CSS中,在widgets.php (加入名單式類型:無;標記所有和雜項嘗試,並刪除小點) 。 Actually, I grew quite fond of the little critter in the end, but knew that most visitors would prefer not to see the bullet, it was far too distracting.其實,我增長了不少喜歡的小critter在年底,但知道大部分的旅客會不希望看到的子彈,這是過於分散。
Finally, after searching the web and reading the manual a dozen times or more I went back to the Automattic site, where it finally dawned on me that a hack they mentioned in regard to formating non-standard sidebars ready to be widgetized might actually work for me too.最後,在網路搜尋和閱讀手冊的十多倍或更多的我回到了automattic網站,在那裡最後的曙光對我說,哈克,他們中提到的關於formating非標準提要欄隨時可以widgetized實際上可能會工作我也是。
To make widgets work in versions of Wordpress pre-2.2 you have to have a file called functions.php in your theme’s folder.使構件的工作版本WordPress的前2.2你必須有一個名為functions.php在您的主題的文件夾。 This file holds nothing but a conditional tag to render the widgetized sidebar as appropriate, but you can add an extra argument or two to make the widget plugin ignore some of the formating in its inbuilt CSS:這個檔案舉行只不過是一個有條件的標記,使widgetized欄適當的,但您可以添加額外的論點或二,使該Widget插件忽略一些對formating在其內在的CSS :
<?php < ? PHP的
if ( function_exists(’register_sidebar’) )如果( function_exists ( ' register_sidebar ' ) )
register_sidebar(array( register_sidebar (陣列(
‘before_widget’ => ”, // Removes the list tag ' before_widget ' = > “ , / /刪除清單標記
‘after_widget’ => ”, // Removes removes the end list entry tag ' after_widget ' = > “ , / /刪除刪除年底列表項標記
‘before_title’ => ”, // Removes the head tag ' before_title ' = > “ , / /刪除頭部標記
‘after_title’ => ”, // Removes the end head tag ' after_title ' = > “ , / /刪除年底頭部標記
)); ) ) ;
?> ? >
Once I’d added this code, fixing the angle brackets to be the actual html enclosures, and reloaded the Sciencebase site up it popped, sans bullet.有一次我要加入這個代碼,固定的角度來看,括號內要實際的HTML罩,重新載入該sciencebase網站,它出現, SAN的子彈。 I will miss the little critter though.我會懷念小critter雖然。






















2 responses so far ↓ 2反應到目前為止↓
Eliena // eliena / / Jun 17, 2007 at 2:35 pm 2007年6月17日在下午2時35分
can i implement this code on my blog page ?我可以執行此代碼對我的博客網頁?
David Bradley 大衛布拉德利 // / / Jun 17, 2007 at 7:02 pm 2007年6月17日在下午7點02分
Sorry Eliena, but I don’t understand why you would want to do that in the first place. eliena抱歉,但我不明白你為什麼想這樣做,擺在首位。 Blogspot is its own system, presumably you have not above blog folders anyway, so what would you be implementing, regardless of the fact the hack is for Wordpress? BlogSpot的是自己的系統,假定你有沒有上述的博客文件夾無論如何,所以你會怎樣實施,無論其事實上,哈克是在WordPress ?
db分貝
Leave a Comment留下意見