====== файл шаблона main.php ====== ''main.php'' включает в себя большинство страниц, которые вы увидите при просмотре установки «ДокуВики»; сюда входят все «действия DokuWiki», перечисленные в менеджере конфигурации. Многие из описанных здесь функций также применимы для ''[[devel:templates:detail.php]]'' и ''[[devel:templates:mediamanager.php]]'', т.е. все, что находится до первого ''div'' плюс ''html_msgarea()'' должно быть общим для всех файлов шаблонов. ===== Минимум... ===== Здесь представлены минимальные требования для правильного отображения и взаимодействия страницы с вашим шаблоном. ==== Functionality ==== Обычно рекомендуется начинать страницы шаблона с типа документа и тега %%%% который сообщает браузеру, какой язык и направление текста используются на вики-страницах. Первый реальный вызов PHP — to ''[[xref>tpl_metaheaders()]]'', который включает в себя CSS и JavaScript, **необходимые ** и предоставляемые DokuWiki, а также все, что собрано из ''style.ini''. Далее идет ''[[xref>tpl_pagetitle()]]'', который использует идентификатор страницы (или, опционально, первый заголовок) в качестве заголовка страницы рядом с заголовком вашей вики ((Это и есть причина ''$conf'' в данном случае.)). Имеет смысл объявить набор символов непосредственно перед этим: <?php tpl_pagetitle()?> - <?php echo hsc($conf['title'])?> To add a favicon you can use ''[[xref>tpl_favicon()]]'' which by default will use the ''favicon.ico'' in the template's ''images'' directory. But this can be overwritten by uploading that file to your wiki's ''wiki'' or root namespace via the media manager. Once you're ready to display, you'll need to add the ''[[xref>tpl_classes()]]'' (which also includes the ''dokuwiki'' class) somewhere at the top so that your page works correctly with plugins that use stylesheets. The ''%%dokuwiki__top%%'' ID is needed for the "Back to top" utility.
Your template should have some consistent header, displaying the wiki's title and tagline:

You'll need all of the utility buttons/links with [[xref>tpl_action()]] to really make your wiki functional. Here are all of the buttons provided by the default template.
Now consider yourself in the content area of your page. First you will need a call to the error display function, ''[[xref>html_msgarea()]]''. This is what allows you to see e.g. configuration errors in DokuWiki whenever you have one, or plugin rendering errors, or lets you see the results of ''do=check'' whenever you add that to the end of a URL on your site. Some odds and ends are "bread crumbs" and "you are here" links. You can add them anywhere in the content area, in any order with ''[[xref>tpl_breadcrumbs()]]'' and ''[[xref>tpl_youarehere()]]'', and they are totally optional and up to your discretion. If you're developing a template for general use, you'll want to support both so your end users can choose.

The climax of the whole process is displaying the content of the page; it's just one call ''[[xref>tpl_content()]]'', and it's used for all actions --- viewing, editing, index navigation, searching, and any page with a form. Nearing the end of the content section, you can add information about when the page was last modified and who did it and as whom you are currently logged in and what the license of the wiki is:



Many templates display a [[faq:sidebar]] when the [[config:sidebar|sidebar config option]] is set. This will display the content of a page called "sidebar": And finally, you **need** this function to ensure that the search is functioning properly and is finding your pages:
=== Altogether now... === We have a small sample, workable ''main.php'' for a template, and it looks like this: <?php tpl_pagetitle()?> - <?php echo hsc($conf['title'])?>



You now have all of the buttons, as well as the search field, and this is about everything you need to develop a template. ==== Look and Feel ==== FIXME An explanation of styles for: * Normal Viewing * Editing * Index Navigation (Or what might typically be called "site map" navigation) * Searching * Form type pages such as registration, profile, administration, configuration, etc. Should go here, as they all require stylesheet information. ===== Source ===== The source of the ''main.php'' of the 'dokuwiki' template can be found at [[xref>lib/tpl/dokuwiki/main.php]]. The [[https://github.com/selfthinker/dokuwiki_template_starter/blob/master/main.php|main.php of the Starter template]] contains even some helpful comments. =====See also===== * [[devel:templates|DokuWiki Template Development]] * [[mediamanager.php]] – the media-selection popup template file * [[detail.php]] – the image detail page template file [[https://www.dokuwiki.org/devel:templates:main.php|оригинал статьи]]