Home › Forums › Porto – Responsive HTML5 Template › Header.php
- This topic has 6 replies, 2 voices, and was last updated 10 years, 8 months ago by
gifbox. This post has been viewed 5370 times
-
AuthorPosts
-
November 3, 2014 at 3:09 pm #10004765
gifbox
ParticipantHi,
I created an Header.php and a footer .php for my website.
Everything works well except the class active on my different links.I tried to use this solution : (works good)
<li <?php if($pageactive == ‘index’) { echo ‘ class=”active”‘; } ?>>
Accueil(with : <?php $pageactive = ‘index’; ?> on my index page)
but it doesn’t work with the dropdown-menu or subcategories. the dropdown works when I click on it but not on the hover ?
Do you have any solutions ?
Thanks
November 4, 2014 at 10:16 am #10004777Support
KeymasterHello, when you set the active class in an item that has a dropdown you need to keep both classes, like this:
Please let me know if you meant something else or if you have any other questions.
Thanks 🙂
November 11, 2014 at 9:09 am #10004899gifbox
ParticipantHello,
I’ve just tried to change the second level of li with “dropdown” class but i’have always the same problem.
If you want to look the new version of my site with the header.php and footer.php it’s hereThanks
November 11, 2014 at 10:00 am #10004907Support
KeymasterHello, here’s a sample of a item with sub-items:
<li class="dropdown"> <a class="dropdown-toggle" href="#"> About Us <i class="fa fa-angle-down"></i> </a> <ul class="dropdown-menu"> <li><a href="about-us.html">About Us</a></li> <li><a href="about-us-basic.html">About Us - Basic</a></li> <li><a href="about-me.html">About Me</a></li> </ul> </li>
And this is when the active class is set:
<li class="dropdown active"> <a class="dropdown-toggle" href="#"> About Us <i class="fa fa-angle-down"></i> </a> <ul class="dropdown-menu"> <li><a href="about-us.html">About Us</a></li> <li><a href="about-us-basic.html">About Us - Basic</a></li> <li><a href="about-me.html">About Me</a></li> </ul> </li>
Please make sure you add the “dropdown” class as well in the parent item as shown above.
Let me know if you have any questions.
Thanks.
November 12, 2014 at 5:59 am #10004936gifbox
ParticipantHi,
My Menu is on a header.php file.
To generate the active class, I have tried ton insert php code in my html.<nav class="nav-main mega-menu"> <ul class="nav nav-pills nav-main" id="mainMenu"> <li <?php if($pageactive == 'index') { echo ' class="active"'; } ?>> <a href="index.php">Accueil</a> </li> <li <?php if($pageactive == 'societe-artificiel-plafond-tendu-barrisol') { echo ' class="active"'; } ?>> <a href="societe-artificiel-plafond-tendu-barrisol.php">La société</a> </li> <li <?php if($pageactive == 'plafond-tendu') { echo ' class="dropdown active"'; } ?>> <a class="dropdown-toggle" href="plafond-tendu.php"> Nos Produits <i class="icon icon-angle-down"></i> </a> <ul class="dropdown-menu"> <li<?php if($pageactive == 'plafond-tendu') { echo ' class="dropdown"'; } ?>> <a href="plafond-tendu.php">Les Plafonds tendus</a> </li> <li<?php if($pageactive == 'plafond-tendu') { echo ' class="dropdown"'; } ?>> <a href="murs-imprimes-artolis.php">Les Murs imprimés</a> </li> <li<?php if($pageactive == 'plafond-tendu') { echo ' class="dropdown"'; } ?>> <a href="pourquoi-plafond-tendu-barrisol.php">Pourquoi choisir Barrisol</a> </li> </ul> </li> <li <?php if($pageactive == 'realisations-plafond-tendu') { echo ' class="dropdown active"'; } ?>> <a class="dropdown-toggle" href="realisations-plafond-tendu.php"> Types de réalisations <i class="icon icon-angle-down"></i> </a> <ul class="dropdown-menu"> <li><a href="realisations-plafond-tendu.php">Tout voir</a></li> <li><a href="realisations-plafond-tendu-salon.php">Salon</a></li> <li><a href="realisations-plafond-tendu-cuisine.php">Cuisine</a></li> <li><a href="realisations-plafond-tendu-salledebain.php">Salle de Bain</a></li> <li><a href="realisations-plafond-tendu-chambres.php">Chambres</a></li> <li><a href="realisations-plafond-tendu-autrespieces.php">Autres pièces</a></li> <li><a href="realisations-plafond-tendu-professionnels.php">Professionnels</a></li> </ul> </li> <li <?php if($pageactive == 'equipe-artificiel') { echo ' class="active"'; } ?>> <a href="equipe-artificiel.php">Notre Equipe</a> </li> <li <?php if($pageactive == 'contact-artificiel-plafond-tendu') { echo ' class="active"'; } ?>> <a href="contact-artificiel-plafond-tendu.php">Contactez Nous</a> </li> </ul> </nav>
I really don’t see where is my problem ? Do I change theme.js ? or anything else ?
Thank you
November 12, 2014 at 10:57 am #10004953Support
KeymasterHello, the problems seems to be that you still need the dropdown class when the item is not active.
For example:
FROM:
<li <?php if($pageactive == 'realisations-plafond-tendu') { echo ' class="dropdown active"'; } ?>>
TO:
<li <?php if($pageactive == 'realisations-plafond-tendu') { echo ' class="dropdown active"'; } else { echo ' class="dropdown"'; } ?>>
Thanks.
November 12, 2014 at 1:20 pm #10004963gifbox
ParticipantYES !!! it’s works perfectely
A Big Thanks for your Help !!
Thanks
-
AuthorPosts
This topic is marked as "RESOLVED" and can not rceive new replies.