anonīms Posted February 9, 2008 Report Share Posted February 9, 2008 (edited) Lapā neizmantoju switch'u. <?php if($ttitle = 'Jaunumi') { echo '<li><a href="..." class="aktivs">Jaunumi</a></li>'; } else { echo '<li><a href="...">Jaunumi</a></li>'; } ?> Katrā lapā ir tā: <?php $ttitle='Jaunumi' include "tmp/augsa.php"; Jaunumu lapa inlude "tmp/apaksa.php"; ?> Uzliekot visai izvēlnei šo kodu, visi linki viņā kļūst aktīvi. Kā būtu iespējams izveidot active link? Ideāli būtu tikai ar css, bez javascript'a Viss iet! Kļūda bija šeit: $ttitle = 'Jaunumi' nomainiju uz $ttitle == 'Jaunumi' Edited February 9, 2008 by anonīms Link to comment Share on other sites More sharing options...
Delfins Posted February 9, 2008 Report Share Posted February 9, 2008 ka'da jēga rakstīt 2x to pašu HTML, ja var iesetot tikai `class` mainīgo un to izvadīt linkā.. Link to comment Share on other sites More sharing options...
anonīms Posted February 9, 2008 Author Report Share Posted February 9, 2008 <li><a href="..." <?php if($ttitle == 'Jaunumi') { echo 'class="aktivs"'; } else { echo''; } ?>>Jaunumi</a></li> Link to comment Share on other sites More sharing options...
Delfins Posted February 9, 2008 Report Share Posted February 9, 2008 Īsāk... <?php echo ($ttitle == 'Jaunumi') ? 'class="aktivs"' : ''; ?> Link to comment Share on other sites More sharing options...
Recommended Posts