I am a designer/front-end developer but I have to move the div with a class of "span-4" before the div with a class of "span-20." The developer who wrote the php is not available to ask how to not mess up his php markup.
Thank you in advance for any help!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>THRIVE</title>
<?php include("header.php"); ?>
</head>
<body>
<div class="container">
<div id="thumbnails" class="span-20 last">
<?php
$accessoriesDir = "images/accessories/";
$collectionCount = 1;
while(is_dir($accessoriesDir . $collectionCount . "/"))
{
$collection_dir = $accessoriesDir . $collectionCount . "/";
if ($season_dh = opendir($collection_dir))
{
$accsArray = array();
$accsCount = 0;
while (($accessoryFolder = readdir($season_dh)) !== false)
{
if(filetype($collection_dir . $accessoryFolder) == "dir" && strlen($accessoryFolder) > 2)
$accsArray[$accsCount++] = $accessoryFolder;
}
closedir($season_dh);
?>
<div id="collection<?php echo $collectionCount?>" class="thumbsHolder <?php if($collectionCount !== 1) echo 'hidden'?>">
<div class="cats span-4">
<?php
foreach($accsArray as $index => $accessory)
{
$class = "accessory-tab";
if($index == 0)
{
$class .= " selected";
}
echo "<a id='".strtolower($accessory)."-tab' class='".$class."'>".$accessory."</a><br/>";
}
?>
</div>
<?php
foreach($accsArray as $index => $accessory)
{
?>
<div id="<?php echo strtolower($accessory);?>-view" class="view <?php if($index != 0) echo 'hidden';?>">
<?php
$imageCount = 0;
$accessoryDir = $collection_dir.$accessory."/";
$dh = opendir($accessoryDir);
while (($file = readdir($dh)) !== false && $imageCount < 8)
{
if(filetype($accessoryDir . $file) == "file" && substr($file, -4) == ".jpg")
{
?>
<div class="thumbnailExpander <?php if($imageCount % 2 !== 0)echo 'expandLeft';?> <?php if($imageCount >= 4)echo 'bottom';?>"
style="left开发者_StackOverflow:<?php echo ($imageCount % 4) * (317-132) ?>px;top:<?php echo 110+((132+53)*intval($imageCount/4));?>px;">
<!--div class="thumbAnchor"-->
<img src="<?php echo $accessoryDir . $file ?>" style=""/>
<!--/div-->
</div>
<?php
$imageCount++;
}
}
?>
</div><!-- #accessory-view -->
<?php
closedir($dh);
}
?>
</div><!-- .thumbsHolder -->
<?php
}
$collectionCount++;
}
?>
</div><!-- #thumbnails -->
<?php include("nav.php"); ?>
<div id="debug" style="color:white"></div>
</div>
</body>
</html>
Refactoring this code so that the span-4 is displayed first is not going to be an easy task. It's going to be near impossible (and not advisable) if you have no PHP experience.
I would suggest that you use CSS to move the span-4 element around on the displayed page. That way you'll not need to touch the PHP. Even better; when the PHP developer returns get them to refactor this so that the display code is not entwined with the business logic (it's a horrible practice that makes questions like this impossible to answer).
Hope that helps some.
Try these two steps:
(1) Cut everything from the first <?php
line after span-20 all the way down to the closing tag of the span-4... and paste it above the span-20 div. This includes all the garbage + the span-4 div in its entirety.
(2) In the code you just pasted, find this line:
<div id="collection<?php echo $collectionCount?>" class="thumbsHolder <?php if($collectionCount !== 1) echo 'hidden'?>">
... and cut & paste it back in the space it where came from.
That should work for you, unless I need to get my eyes checked.
EDIT: There's a chance it won't work, depending on whether the span-4 really needs to be a child of #collection. If that's the case, you'll need to tuck into the CSS and separate the two, or somehow carry the parent id out with the span-4.
精彩评论