Jump to content

[SOLVED] new line after div...let php pick up on that....


DjMikeS

Recommended Posts

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 ?

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.

@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.

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.

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();
?>

 

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();
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.