====== 命名空間 Namespaces ====== 若將頁面比擬成檔案,那麼命名空間就有如資料夾(或目錄)。 在DokuWiki中,可以使用命名空間來歸納頁面。命名空間的名稱限制與頁面名稱相同。 ===== 建立命名空間 Creating Namespaces ===== 命名空間毋須事先建立,只要在建立頁面時,[[zh-tw:pagename|頁面名稱]]裏加上冒號即可,最後一個冒號之後的是頁面名稱,之前的則都是命名空間。若該命名空間尚未建立,系統會自動建立。 (在DokuWiki裏建立頁面的方式與其他wiki一樣,只要建立一個連結指向尚未建立的頁面,然後點擊該連結,再使用「編修頁面」來建立該頁面。) [[.:page#create_a_page|新增頁面]]. ^範例:^^ |example\\ .example\\ .:example|表示**當前**命名空間裏的"example"頁面。| |:example|refers to the page "表示**根部**命名空間裏的"example"頁面。| |..example\\ ..:example\\ .:..:example|表示**上層**命名空間裏的"example"頁面。| |wiki:example|表示位於"wiki"命名空間裏的"example"頁面。而"wiki"為位於**根部之下**的命名空間。| |ns1:ns2:example\\ :ns1:ns2:example|表示在命名空間"ns2"裏的"example"頁面;而"ns2"為位於命名空間"ns1"之下的命名空間,"ns1"為位於**根部之下**的命名空間。| |.ns1:ns2:example\\ .:ns1:ns2:example|表示位於命名空間"ns2"裏的"example"頁面;而"ns2"為位於命名空間"ns1"之下的命名空間,"ns1"為位於**當前命名空間之下**的命名空間。| |..ns1:ns2:example\\ ..:ns1:ns2:example|表示位於命名空間"ns2"裏的"example"頁面;而"ns2"為位於命名空間"ns1"之下的命名空間,"ns1"為位於**與當前命名空間平行**的命名空間。(當前的命名空間與ns1都同樣位於某個上層命名空間裏)| |.ns1:ns2:|表示位於命名空間"ns2"裏的"start"頁面;而"ns2"為位於命名空間"ns1"之下的命名空間,"ns1"為位於**當前命名空間之下**的命名空間。\\ \\ (start為初始頁面,可以利用configuration setting裏的[[config:startpage]]來修改成其他的名稱。)| ===== 刪除命名空間 Deleting Namespaces ===== 當某個命名空間裏的頁面都被移除,邏輯上這個命名空間也不復存在。Dokuwiki通常也會刪除這個已被清空的目錄。 ===== 如何修改命名空間的名稱? How to rename namespaces? ===== ==== 手動方式 ==== 必須完成以下步驟: * 修改Server端的表示該命名稱間的資料夾名稱: * ''data/pages'' * ''data/media'' (如果有的話) * 移除''data/meta''內的資料原資料 * 移除''data/attic''內的歷史紀錄資料(如果你想保留舊版紀錄,也可以把它們移到別的地方) 例如,在Unix主機上,你可以這樣做: * ''mv /dokuwiki_base/data/pages/old_namespace /dokuwiki_base/data/pages/new_namespace'' * ''mv /dokuwiki_base/data/media/old_namespace /dokuwiki_base/data/media/new_namespace'' * ''rm -Rf /dokuwiki_base/data/meta/old_namespace'' * ''rm -Rf /dokuwiki_base/data/attic/old_namespace'' 請注意,若不是拉丁系字碼,''old_namespace''以及/或是''new_namespace''要先編碼過。(如希臘文、俄文等等) * (經由編輯鏈結)修正指向//已移除的//命名空間下所有頁面的鏈結(在移除命名空間之前,你可以反向鏈結(backlink)找到需要修改的鏈結)。 * 檢視新的命名空間中所有的頁面,以重建頁面的索引資訊和metadata。 However, you will still have lots of junk left around. For example in ''data/changes.log'', various files under cache (including the ''.idx'' files etc). If possible you could just start from a ''blank state'' as follows (again under Unix) but be warned that this will mean losing all your historical information (ie ''recent changes''): * ''cat /dev/null > /dokuwiki_base/data/changes.log'' * ''rm -Rf /dokuwiki_base/data/attic/*'' * ''rm -Rf /dokuwiki_base/data/cache/?'' * ''rm -Rf /dokuwiki_base/data/cache/*.idx'' * ''rm -Rf /dokuwiki_base/data/cache/purgefile'' * Browse each and every page of your Wiki. DISCLAIMER : I understand this is convoluted (and maybe I missed/messed a couple of things you should also do). All in all this is a PITA. You may also use a couple of [[plugins]] that are available for (re)building the searchindex for the complete wiki, erasing entire cache and/or old wiki revisions thus avoiding to do this manually. ==== 使用外掛 Plugin way ==== 你可以使用第三方開發者所提供的[[plugin:PageMove]]外掛來將某個命名空間裏的每個頁面搬到新的命名空間裏。請先參閱相關資料以確認是否符合你的需要。 ===== Namespace Default Linking ===== It is possible to link to a default file of a namespace ending the linkid with a colon: %%[[foo:bar:]]%%. To which page the link links is dependent on the existence of certain named files. For %%[[foo:bar:]]%% the following pages are checked: foo:bar:$conf['start'] foo:bar:bar foo:bar The pages are checked in that order and whatever page is found first will be linked to. Autoplural linking is not done for those links :!: **This feature is only available in 2006-09-28 RC1 version and above.**