Php 带位置和重量的模板
嗨,我正在尝试创建一个模板,我可以动态地把我的模块放在模板的任何位置 我的模板将具有以下位置:Php 带位置和重量的模板,php,html,Php,Html,嗨,我正在尝试创建一个模板,我可以动态地把我的模块放在模板的任何位置 我的模板将具有以下位置: 内容(上) 底部的内容 左栏 右栏 中间的 index.php <html> <head> <title>Template with dynamic positions</title> </head> <body> <?php include('header.php'); ?> <div class="cont
<html>
<head>
<title>Template with dynamic positions</title>
</head>
<body>
<?php include('header.php'); ?>
<div class="content">
<div class="content_top">All content top will go here</div>
<div class="column_left">All content left will go here</div>
<div class="column_right">All content right will go here</div>
<div class="content_bottom">All content bottom will go here</div>
</div>
<?php include('footer.php'); ?>
</body>
</html>
具有动态位置的模板
所有内容都将放在这里
所有剩下的内容都将放在这里
所有的内容都在这里
所有内容都将放在这里
假设我创建了一个模块,我想将其添加到content_top,权重为0
module-top.php
$weight = $_GET['weight'];
<div class="slideshow-<?php echo $weight ?>">
<img src="banner.jpg" alt="" />
</div>
$weight=$\u GET['weight'];
试试这个:
<div class="content_top"><?php include('module-top.php'); ?></div>
编辑:
您必须使用javascript对其进行排序。您可以使用气泡排序。
像这样:
var slideshows = $('.content_top div');
var len = slideshows.length;
for(var i = 0;i<len;i++)
for(var j = 0;j < len - 1; j++)
{
slideshows = $('.content_top div');
if(parseInt(slideshows[j].attr('class').replace('slideshow-', '')) > parseInt(slideshows[j + 1].attr('class').replace('slideshow-', '')))
{
slideshows[j].before(slideshows[j+1]);
slideshows[j+1].remove();
}
}
var slideshows=$('.content_top div');
var len=幻灯片放映。长度;
对于(var i=0;i parseInt(幻灯片[j+1].attr('class')。replace('slideshow-',''))
{
幻灯片放映[j]。之前(幻灯片放映[j+1]);
幻灯片放映[j+1]。删除();
}
}
这是泡沫式的。这将对content\u top
中的所有div进行排序,包括content\u top div中的php文件
<div class="content_top">
<?php include('module-top.php'); ?>
</div>
重量如何?。如果我有两个模块,我将把0和1放入模块。0应先于1。如何检查重量?您从哪里获得此$weight
?我是说哪个文件?你能用javascript吗?是的,我能用javascript。如何检测权重并正确定位它们?比如foreach($module as$modules){检查权重并回显模块}但是如何检查权重呢?如果我有两个模块在同一个内容中\u top div,权重分别为0和1?权重??代码中没有称为weights的变量,这是由用户动态设置的,例如在input$_GET['weight']中;