PHP:链接一个块

时间:2016-04-01 08:34:16

标签: php

快速提问,我想将BLOCK1链接到另一个页面。可能吗?有没有人有解决方案?我试过abit,我的脑子发疯了T_T。还有5个其他块可以链接到其他页面。

这是下面的代码:

             

 <div class="midrow_block axn_block1">
            <div class="mid_block_content">

              <!--BLOCK1 IMAGE-->
              <?php if(!empty($optimizer['block1_image']['url']) && empty($optimizer['block1_img_bg'])){   ?>
                  <div class="block_img"><img src="<?php echo $optimizer['block1_image']['url']; ?>" width="<?php echo $optimizer['block1_image']['width']; ?>" height="<?php echo $optimizer['block1_image']['height']; ?>" /></div>
              <?php } ?>

             <div class="block_content">
                  <h3>
                  <?php echo do_shortcode( $optimizer['block1_text_id']); ?>
                  </h3>
                  <?php echo do_shortcode($optimizer['block1_textarea_id']); ?>
              </div>


            </div>
        </div>
     </div>

        <?php } ?>
        <!--BLOCK1 END-->

3 个答案:

答案 0 :(得分:0)

只需添加一个<a> - 标记您想要链接的块:

<a href="'your link here'"> <!-- start link here -->
    <div class="midrow_block axn_block1">
        <div class="mid_block_content">

          <!--BLOCK1 IMAGE-->
          <?php if(!empty($optimizer['block1_image']['url']) && empty($optimizer['block1_img_bg'])){   ?>
              <div class="block_img"><img src="<?php echo $optimizer['block1_image']['url']; ?>" width="<?php echo $optimizer['block1_image']['width']; ?>" height="<?php echo $optimizer['block1_image']['height']; ?>" /></div>
          <?php } ?>

         <div class="block_content">
              <h3>
              <?php echo do_shortcode( $optimizer['block1_text_id']); ?>
              </h3>
              <?php echo do_shortcode($optimizer['block1_textarea_id']); ?>
          </div>


        </div>
    </div>
 </a> <!-- end link here -->

或者将它放在您想要链接的任何其他部分周围。它只是基本的HTML,与PHP无关。

答案 1 :(得分:0)

这是块的完整代码。我错过了复制它的顶部:

       <?php if ((!empty ($optimizer['block1_text_id'])) || (!empty ($optimizer['block1_textarea_id']))  ) { ?> 


         <div class="midrow_block axn_block1">
            <div class="mid_block_content">

              <!--BLOCK1 IMAGE-->
              <?php if(!empty($optimizer['block1_image']['url']) && empty($optimizer['block1_img_bg'])){   ?>
                  <div class="block_img"><img src="<?php echo $optimizer['block1_image']['url']; ?>" width="<?php echo $optimizer['block1_image']['width']; ?>" height="<?php echo $optimizer['block1_image']['height']; ?>" /></div>
              <?php } ?>

             <div class="block_content">
                  <h3>
                  <?php echo do_shortcode( $optimizer['block1_text_id']); ?>
                  </h3>
                  <?php echo do_shortcode($optimizer['block1_textarea_id']); ?>
              </div>


            </div>
        </div>

答案 2 :(得分:0)

您可以使用此JS

    $("div").click(function(){
   window.location=$(this).find("a").attr("href"); return false;
});

jQuery的:

{{1}}