dragon_9000 2010-10-21 19:06
浏览 59

试图在另一个div之前移动一个div而不搞砸我不明白的PHP :)

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:<?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>
  • 写回答

2条回答 默认 最新

  • duanbi3151 2010-10-21 19:20
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)