DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:pageaccueil

Page d'accueil / Home page

Permet de créer facilement des nouvelles pages dans des catégories voulues - Allows you to easily create new pages into appropriate categories

author: Anthony Prévost

Objet / Object

Permet de créer une page d'accueil qui liste les catégories du wiki et permet de créer une nouvelle page dans la catégorie choisie. Permet aussi de créer une nouvelle catégorie.
La liste des catégories est aussi affichée sur la droite.

Creates a home page that lists categories of wiki to create a new page in the category chosen. Also allows to Create a new category.
The list of categories is also displayed on the right.

Exemple / Sample

Plugin

Copier le code ci-dessous dans le contenu de la page start.

Copy the code below into the contents of the home page.

Code

~~NOCACHE~~ 
<php>
require_once(DOKU_INC.'inc/search.php');
    global $conf;
    global $ID;
    $dir = $conf['datadir'];
    $ns  = cleanID($ns);
    #fixme use appropriate function
    if(empty($ns)){
        $ns = dirname(str_replace(':','/',$ID));
        if($ns == '.') $ns ='';
    }
    $ns  = utf8_encodeFN(str_replace(':','/',$ns));
 
 
 
    echo '<div id="index__tree" style="position:absolute;top:170px;width:95px;background: #dfd;border: 1px solid #9d9;>';
 
    $data = array();
    search($data,$conf['datadir'],'search_index',array('ns' => $ns));
    echo html_buildlist($data,'idx','html_list_index','html_li_index');
 
    echo '&nbsp;</div>';
 
 
function search2(&$data,$base,$func,$opts,$dir='',$lvl=1){
    $n=0;
    $dirs   = array();
    $files  = array();
 
    //read in directories and files
    $dh = @opendir($base.'/'.$dir);
    if(!$dh) return;
    while(($file = readdir($dh)) !== false){
        if(preg_match('/^[\._]/',$file)) continue; //skip hidden files and upper dirs
        if(is_dir($base.'/'.$dir.'/'.$file)){
            $dirs[] = $dir.'/'.$file;
 
 
            $tony = $tony.'liste['.$n.']="'.$file.'";';
            $n=$n+1;
            continue;
        }
        $files[] = $dir.'/'.$file;
 
    }
    closedir($dh);
    sort($files);
    sort($dirs);
 
return $tony;
 
    }
 
echo '<script>';
echo 'var liste = new Array();</script>';
$tony=search2($data,$conf['datadir'],'search_index',array('ns' => $ns));
echo '<script>'.$tony.'</script>';
</php>
 
 
 
<html>
<body onload="">
<form class="button btn_create" method="post" action="/doku.php?do=index" name=tony>
 
 
<style>
.ap {font-family:tahoma;font-size:12px}
.b {font-family:tahoma;font-size:12px;width:150;background: #e0e0e0;; }
.tony {font-family:tahoma;font-size:12px;background: #ffffff;;font-weight:bold;color: #000080 }
TD {font-family:tahoma;font-size:12px;background: #ffffff;text-align:left;font-weight:bold;color: #000080 }
.TD2 {font-family:tahoma;font-size:14px;background: #e0e0e0;;font-weight:bold;color: #000080 }
.tony2 {font-family:tahoma;font-size:12px;background: #ffffff;;font-weight:bold;color: #000080 }
.tony3 {font-family:tahoma;font-size:8px;background: #ffffff;;font-weight:bold;color: #000080 }
.tony3_2 {font-family:tahoma;font-size:8px;background: #000080;;font-weight:bold;color: #e0e0e0 }
.c {font-family:tahoma;font-size:10px;background: #87CEFA;;font-weight:bold;color: #000080 }
input {font-family:tahoma;font-size:12px;}
textarea {font-family:tahoma;font-size:12px;}
select {font-family:tahoma;font-size:12px;}
A:link     {font-family: tahoma, arial, geneva, sans-serif; font-size: 12px; text-decoration: underline; color: #0088bb}
A:visited  {font-family: tahoma, arial, geneva, sans-serif; font-size: 12px; text-decoration: underline; color: #0088bb}
A:hover    {font-family: tahoma, arial, geneva, sans-serif; font-size: 12px; text-decoration: none; color: #008000;}
</style>
<center>&nbsp;&nbsp;
<span id=k2000></span>
&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</center>
 
 
<b><span style="cursor:hand" onclick='window.location="doku.php?do=index&id=accueil"'>Index</span></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b><span>Créer une nouvelle page</span></b>
<br>
<br>
<div id=maliste></div>
 
<style>
TD {background: #dfd}
</style>
 
<script>
 
 
function code(an)
{	
	liste.sort()
	a=''
        a=a+'<center><div style="width:950px;background: #dfd;border: 0px solid #9d9;">'
	a=a+'<table border=0 cellspacing=2 cellpadding=2 style="background: #dfd;"><tr><td colspan=3>&nbsp;</td></tr>'
	a=a+'<tr><td rowspan=4 width=20px>&nbsp;</td><td>'
	a=a+'Choix de la catégorie</td><td><select id="sel" class="edit" name=sel onfocus=this.select size=8>'
	for(var i=0;i<liste.length;i++)
	{
		if(liste[i]!='wiki' && liste[i] !='playground' && liste[i]!='Wiki' && liste[i] !='Playground')
		{
			a=a+'<option value="'+liste[i]+'" '
			if((i==0 &&  an =='') || (liste[i]==an && an !=''))
                        {a=a+'selected'}
 
                        a=a+'>'+liste[i]+'</option>'
		}
	}
 
	a=a+'</select></td></tr>'
	a=a+'<tr><td>Titre de la page</td><td><input type=text size=100 id="taixt" name="taixt"  class="edit" onfocus="this.select()" value="">'
	a=a+'&nbsp;&nbsp;<input type=button value="Créer cette page" class="button" accesskey="e" title="Créer cette page [E]"  onclick="lance()" /></td></tr>'
	a=a+'<tr><td height=20px>&nbsp;</td></tr>'
	a=a+'<tr><td>Ajouter une nouvelle catégorie&nbsp;&nbsp;</td><td><input type=text size=40 id="ajout" name="ajout"  class="edit" value="">'
	a=a+'&nbsp;&nbsp;<input type=button value="Ajouter une nouvelle catégorie" class="button" onclick="aj()"></td></tr>'
	a=a+'</table></div></center>'
 
	document.getElementById('maliste').innerHTML=a
 
        if(an !='')
                        {document.getElementById('taixt').focus()}
 
}
 
code('')
document.getElementById('sel').focus()
function aj()
{if(document.tony.ajout.value=='')return false;
var an=liste.length
 
var chaine=document.tony.ajout.value
var chaine1= chaine.substring(0,1)
var chaine2= chaine.substring(1)
chaine= chaine1.toUpperCase()+ chaine2.toLowerCase()
document.tony.ajout.value=chaine
 
liste[an]=document.tony.ajout.value
document.tony.ajout.value=""
code(liste[an])
}
 
function Remplacer(a)
{
var a, tmp;
tmp = "";
 
	for(var i = 0; i < a.length; i++)
	{tmp = tmp + a.charAt(i);
		if (a.charAt(i) == ":")	{	tmp = tmp.replace(":"," _ ");	}
	}
a = tmp;
 
return a;
}
 
</script>
 
<input type="hidden" name="do" value="edit" />
<input type="hidden" name="rev" value="" />
<input type="hidden" name="id" value="" />
 
<script>
 
function lance()
{if(document.tony.taixt.value=='')
{alert('Il faut saisir le titre de la page')
return false;}
document.tony.taixt.value=Remplacer(document.tony.taixt.value)
document.getElementById('qsearch__in').value=document.getElementById('sel').options[document.getElementById('sel').selectedIndex].value+":"+document.tony.taixt.value
document.tony.id.value=document.getElementById('sel').options[document.getElementById('sel').selectedIndex].value+":"+document.tony.taixt.value
document.tony.submit()
 
}
</script>
 
<script>
 
 
k2000text  = "";
k2000pos = 0;
k2000increment = 1;
 
k2000text='- Bienvenue sur le wiki -'
 
function k2000effet() 
	{
 
	k2000aff = ""
	for(k2000a=0;k2000a<k2000text.length;k2000a++)
		{
		k2000lettre = k2000text.charAt(k2000a);
		if(k2000a == k2000pos || k2000a == (k2000pos+k2000increment))
			k2000aff += "<FONT COLOR=#0000ef face=tahoma size=5><b>"+k2000lettre+"</b></FONT>";
		else
			k2000aff += "<FONT COLOR=black  face=tahoma size=6><b>"+k2000lettre+"</b></FONT>";;
		}
	document.getElementById("k2000").innerHTML = k2000aff;
	if(k2000pos == k2000text.length)
		k2000increment = -1;
	if(k2000pos == 0 && k2000increment== -1)
		k2000increment = 1;
	k2000pos = k2000pos+k2000increment;
	timer = setTimeout("k2000effet()",200)
}
 
 
</script>
 
<script>
k2000effet() 
</script>
 
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
 
<b><span>Liens utiles</span></b>
</form>
 
</body>
</html>
 
<note tip>
{{:nfleche.gif|}}[[wiki:syntax|Syntaxe du Wiki]] \\
{{:nfleche.gif|}}[[wiki:dokuwiki|Documentation sur le Wiki]] \\
</note>

Discussion

Cela ne fonctionne pas si je copie cela dans la page se terminant par “doku.php?id=Accueil&do=edit&rev=”

L'aperçu ne marche pas mais si tu enregistres la page, ça doit marcher.
Tu as quoi comme erreur?

J'ai activé le php et la html dans la console d'admin

Excuse me… What home page you are talking about?… Where do I paste this code?
tips/pageaccueil.txt · Last modified: 2015-04-17 18:13 by Aleksandr

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki