DjMikeS Posted October 2, 2008 Share Posted October 2, 2008 Freaks, I have a problem which I can't figure out...I think I'm trying to hard so that I end up with all sorts of difficult solutions....while the problem is easy... and I think the solution is too... The problem: I'm building a menu which you can see here: https://dev.phison.nl/phison/ The problem is that the active link is displayed inside a div which means a new line after the div. The next link however has 2 breaks before it, making the space between the active link and the next link one break too much. Code: <?php require $site_path . 'sec_news/functions/show_news.php'; $cntBuffer = new DataBuffer(); $arrLinks = array('home.0', 'news.1', 'services.0', 'downloads.0'); foreach ($arrLinks as $strLink) { $arrLink = explode (".", $strLink); $strUcfSection = ucfirst($arrLink[0]); if ($registry['section'] == $arrLink[0]) { echo "<br /><br /><div class=\"div_link_active\"><a href=\"index.php?section=$arrLink[0]\" class=\"mm\">$strUcfSection </a>\n"; if ($arrLink[1] == 1) { echo "<br /><span style=\"font-weight: normal;\">"; $rows = 2; showNews($rows); echo "</span>"; } echo "</div>\n"; } else { echo "<br /><br /><a href=\"index.php?section=$arrLink[0]\" class=\"mm\">$strUcfSection </a>\n"; } } $cntMainMenu = $cntBuffer->close(); ?> What I want is to have equal space below the link wether the div is displayed or not... Do you know how to achieve this ? Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/ Share on other sites More sharing options...
genericnumber1 Posted October 2, 2008 Share Posted October 2, 2008 spacing and all of that is controlled by the html/css.. so look to that for the problem. I'm not quite sure what you want, but try moving the two br tags above the foreach() loop, that will stop it from having br tags between the divs, only above the top one. Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655863 Share on other sites More sharing options...
DjMikeS Posted October 2, 2008 Author Share Posted October 2, 2008 @generic: Have you looked at the menu? Example: It displays links like this: test1 test2 test3 Which is good. But when a link is active, it is placed in a div. I want that too. Downside is that a div automatically adds a break at the end. so now the menu looks like this: test1 (<- active) test2 test3 I want to remove one line break so that the menu has 2 breaks between each link. Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655869 Share on other sites More sharing options...
genericnumber1 Posted October 2, 2008 Share Posted October 2, 2008 Nope I didn't look it, your certificate isn't signed properly and my browser makes you jump through hoops to visit a site such as yours... and unfortunately the page doesn't work in http. As for not wanting the div to add a line break... use <span>. It's the same thing as div, just no line break. Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655875 Share on other sites More sharing options...
DjMikeS Posted October 2, 2008 Author Share Posted October 2, 2008 I've tried using a span, but that makes the layout all screwed up... Is there another solution ? PS, I'll make the site available through http...http://dev.phison.nl/phison/ Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655878 Share on other sites More sharing options...
DarkWater Posted October 2, 2008 Share Posted October 2, 2008 div { padding: 0; margin: 0; } Try that in your CSS. Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655881 Share on other sites More sharing options...
genericnumber1 Posted October 2, 2008 Share Posted October 2, 2008 or to be more specific .div_link_active { padding: 0; margin: 0; } Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655883 Share on other sites More sharing options...
DjMikeS Posted October 2, 2008 Author Share Posted October 2, 2008 I've got it! I just needed to set a variable if the link is active, and then let the next link pick up on that and unset the variable. Code: <?php require $site_path . 'sec_news/functions/show_news.php'; $cntBuffer = new DataBuffer(); $arrLinks = array('home.0', 'news.1', 'services.0', 'downloads.0'); foreach ($arrLinks as $strLink) { $arrLink = explode (".", $strLink); $strUcfSection = ucfirst($arrLink[0]); if ($registry['section'] == $arrLink[0]) { $div = true; echo "<br /><br /><div class=\"div_link_active\"><a href=\"index.php?section=$arrLink[0]\" class=\"mm\">$strUcfSection </a>\n"; if ($arrLink[1] == 1) { echo "<br /><span style=\"font-weight: normal;\">"; $rows = 2; showNews($rows); echo "</span>"; } echo "</div>\n"; } else { if (isset($div)) { echo "<br /><a href=\"index.php?section=$arrLink[0]\" class=\"mm\">$strUcfSection </a>\n"; unset ($div); } else { echo "<br /><br /><a href=\"index.php?section=$arrLink[0]\" class=\"mm\">$strUcfSection </a>\n"; } } } $cntMainMenu = $cntBuffer->close(); ?> Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655893 Share on other sites More sharing options...
thebadbad Posted October 2, 2008 Share Posted October 2, 2008 Yup, but you don't need to repeat the whole link: <?php require $site_path . 'sec_news/functions/show_news.php'; $cntBuffer = new DataBuffer(); $arrLinks = array('home.0', 'news.1', 'services.0', 'downloads.0'); foreach ($arrLinks as $strLink) { $arrLink = explode (".", $strLink); $strUcfSection = ucfirst($arrLink[0]); if ($registry['section'] == $arrLink[0]) { $div = true; echo "<br /><br /><div class=\"div_link_active\"><a href=\"index.php?section=$arrLink[0]\" class=\"mm\">$strUcfSection </a>\n"; if ($arrLink[1] == 1) { echo "<br /><span style=\"font-weight: normal;\">"; $rows = 2; showNews($rows); echo "</span>"; } echo "</div>\n"; } else { if (!isset($div)) {echo '<br />';} echo "<br /><a href=\"index.php?section=$arrLink[0]\" class=\"mm\">$strUcfSection </a>\n"; unset($div); } } $cntMainMenu = $cntBuffer->close(); ?> Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655896 Share on other sites More sharing options...
DjMikeS Posted October 2, 2008 Author Share Posted October 2, 2008 True, you're right, that's the nicer solution...thanks! Link to comment https://forums.phpfreaks.com/topic/126798-solved-new-line-after-divlet-php-pick-up-on-that/#findComment-655899 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.