Indexation des pages ...

Résolu/Fermé
triskaal - 29 sept. 2015 à 16:43
Pitet Messages postés 2826 Date d'inscription lundi 11 février 2013 Statut Membre Dernière intervention 21 juillet 2022 - 2 oct. 2015 à 14:21
Bonjour,
j'ai une petite question de débutant.
très débutant
j'include un fichier dans un autre en php (pas de soucis jusque là)
ca donne qqlq chose comme
:
page 1 page 2 page 3 page 4 page 5 etc
donc voici ma question: comment puis je faire pour que l'utilisateur reconnaisse sur quelle page il est, pour que par exemple s'il est sur la page 3, la page 3 est sélectionnée d'une manière ou d'une autre (souligné, entouré, grossit, colorié, etc)

avez-vous des astuces svp et j'espère avoir été clair et désolé si cela n'est pas le cas

merci d'avance

4 réponses

Pitet Messages postés 2826 Date d'inscription lundi 11 février 2013 Statut Membre Dernière intervention 21 juillet 2022 524
30 sept. 2015 à 14:08
Salut,

En général on compare l'url saisie par l'utilisateur avec les différentes pages pour définir quelle est la page consulté.

Peux tu nous montrer ton code afin que nous puissions mieux te guider ?

Bonne journée
0
Salut,
oui bien sur
je me doutais que j'avais pas été très clair lol
voici le fichier que j'include (modifié pour pas qu'on voit tout)*

ma question est donc la suivante.
la garq qui se trouve page 6 arce qu'il a cliqué, comme,nt faire pour qu'il voie qu'il est sur la page 6. Comment le mettre à ce qui correspondrait à "selected" en html.


<h6>

<a href= "http://SITEINTERNET/video_page1.html"
title="Page 1" target="_self">1</a>    

<a href= "http://SITEINTERNET/video_page2.html"
title="Page 2" target="_self">2</a>    

<a href= "http://SITEINTERNET/video_page3.html"
title="Page 3" target="_self">3</a>    

<a href= "http://SITEINTERNET/video_page4.html"
title="Page 4" target="_self">4</a>    

<a href= "http://SITEINTERNET/video_page5.html"
title="Page 5" target="_self">5</a>    

<a href= "http://SITEINTERNET/video_page6.html"
title="Page 6" target="_self">6</a>    

<a href= "http://SITEINTERNET/video_page7.html"
title="Page 7" target="_self">7</a>    

<a href= "http://SITEINTERNET/video_page8.html"
title="Page 8" target="_self">8</a>    

<a href= "http://SITEINTERNET/video_page9.html"
title="Page 9" target="_self">9</a>    

<a href= "http://SITEINTERNET/video_page10.html"
title="Page 10" target="_self">10</a>    

<a href= "http://SITEINTERNET/video_page11.html"
title="Page 11" target="_self">11</a>    

<a href= "http://SITEINTERNET/video_page12.html"
title="Page 12" target="_self">12</a>    

<a href= "http://SITEINTERNET/video_page13.html"
title="Page 13" target="_self">13</a>    

<a href= "http://SITEINTERNET/video_page14.html"
title="Page 14" target="_self">14</a>    

<a href= "http://SITEINTERNET/video_page15.html"
title="Page 15" target="_self">15</a>    

<a href= "http://SITEINTERNET/video_page16.html"
title="Page 16" target="_self">16</a>    

<a href= "http://SITEINTERNET/video_page17.html"
title="Page 17" target="_self">17</a>    

<a href= "http://SITEINTERNET/video_page18.html"
title="Page 18" target="_self">18</a>    

<a href= "http://SITEINTERNET/video_page19.html"
title="Page 19" target="_self">19</a>    

<a href= "http://SITEINTERNET/video_page20.html"
title="Page 20" target="_self">20</a>    

<a href= "http://SITEINTERNET/video_page21.html"
title="Page 21" target="_self">21</a>    

<a href= "http://SITEINTERNET/video_page22.html"
title="Page 22" target="_self">22</a>    

<a href= "http://SITEINTERNET/video_page23.html"
title="Page 23" target="_self">23</a>    

<a href= "http://SITEINTERNET/video_page24.html"
title="Page 24" target="_self">24</a>    

<a href= "http://SITEINTERNET/video_page25.html"
title="Page 25" target="_self">25</a>    

<a href= "http://SITEINTERNET/video_page26.html"
title="Page 26" target="_self">26</a>    

<a href= "http://SITEINTERNET/video_page27.html"
title="Page 27" target="_self">27</a>    

<a href= "http://SITEINTERNET/video_page28.html"
title="Page 28" target="_self">28</a>    

<a href= "http://SITEINTERNET/video_page29.html"
title="Page 29" target="_self">29</a>    
<a href= "http://SITEINTERNET/video_page30.html"
title="Page 30" target="_self">30</a>    
<a href= "http://SITEINTERNET/video_page31.html"
title="Page 31" target="_self">31</a>    
<a href= "http://SITEINTERNET/video_page32.html"
title="Page 32" target="_self">32</a>   
</a></h6>
0
Pitet Messages postés 2826 Date d'inscription lundi 11 février 2013 Statut Membre Dernière intervention 21 juillet 2022 524
1 oct. 2015 à 09:44
Une solution possible est de récupérer l'url courante via la superglobale $_SERVER['REQUEST_URI']. On peut utiliser strtok() sur cette variable pour ne pas récupérer les éventuelles paramètres dans l'url.

On compare ensuite l'url courante à tous les éléments de menu pour définir quel est le menu actif en lui appliquant simplement une classe "active". Il suffit ensuite de styliser comme on le souhaite cette classe css.

Un exemple :
<?php

$curPage = strtok($_SERVER["REQUEST_URI"], '?');

?>

<style>
.active {
	color: red;
}
</style>

<a href="http://SITEINTERNET/video_page1.html" title="Page 1" target="_self"<?php echo $curPage == '/video_page1.php' ? ' class="active"' : ''; ?>>1</a>

<a href="http://SITEINTERNET/video_page2.html" title="Page 2" target="_self"<?php echo $curPage == '/video_page2.html' ? ' class="active"' : ''; ?>>2</a>    

<a href="http://SITEINTERNET/video_page3.html" title="Page 3" target="_self"<?php echo $curPage == '/video_page3.html' ? ' class="active"' : ''; ?>>3</a>


Bonne journée
0
merci beaucoup d'avoir prit le temps de me répondre.
c'est super cool
je suppose que je dois placer ceci dans la page dans lequel j'indique <?php include ?> et non dans la page que j'"include" <?php

$curPage = strtok($_SERVER["REQUEST_URI"], '?');

?>
merci beaucoup encore
0
Pitet Messages postés 2826 Date d'inscription lundi 11 février 2013 Statut Membre Dernière intervention 21 juillet 2022 524
2 oct. 2015 à 14:21
Tu peux initialiser la variable $curPage dans l'un ou l'autre fichier, tu ne devrais pas avoir de problème de portée tant que tu initialises la variable avant de l'utiliser.
0