我有以下情况.我有一个具有以下属性的模型A:id int name varchar(255)parent_id int(引用相同的模型A).
现在,我需要使用ModelA渲染树视图.当然,我可以加载所有数据,通过parent_id正确排序,并使用传统的字符串粘贴"渲染".例如
class Model_A extends Model_Table {
...
function render_branch($nodes, $parent){
if (!isset($nodes[$parent])){
return null;
}
$out = "<ul>";
foreach ($nodes[$parent] as $node){
$out .= "<li>" . $node["name"];
$out .= $this->render_branch($nodes, $node["id"]);
$out .= "</li>";
}
return $out;
}
function init(){
parent::init();
$nodes = array(); // preload from db and arrange so that key = parent and content is array of childs
$this->template->set("tree", $this->render_branch($nodes, 0));
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我想改为使用atk4 native lister/smlite模板解析器.但是,如果你试图这样做,那么你最终会遇到讨厌的lister,在格式行中,你无论如何都会尝试用其他lister的输出替换特定标记,实际上你必须破坏运行时内存溢出.
有什么建议?
上面的ps代码没有经过测试,只是显示了概念
谢谢!
这是我的目录树:
在我的head.php和connect.php都有:
include_once 'include/functions.php';
Run Code Online (Sandbox Code Playgroud)
我在根文件夹中的index.php包括以下两个:head.php和connect.php,如下所示:
include_once 'include/connect.php';
include_once 'include/head.php;'
Run Code Online (Sandbox Code Playgroud)
但是,当sub /中的index.php包含functions.php和head.php时,它们将无法包含functions.php.这是我在sub/index.php中包含的内容:
include_once '../include/connect.php';
include_once '../include/head.php';
Run Code Online (Sandbox Code Playgroud)
如果我将head.php和connect.php更改为:include_once'../include/functions.php';
sub/index.php通常会包含所有内容,但root中的index.php将无法加载functions.php.
我怎样才能解决这个问题?
PHP版本:5.2.*
我一直在寻找这个,似乎无法找到一个有效的anwser.我所拥有的是带有箭头和按钮的滑块,当单击箭头或按钮时,该函数会抓取data-cs属性,用于确定下一张幻灯片.
HTML
<div id="arrowleft" class="sliderbtns flip" data-sc="prev"></div>
<div id="arrowright" class="sliderbtns" data-sc="next"></div>
<div id="buttons" class="sliderbtns">
<div class="selectedbtn sliderbtns" id="button1" data-sc="1"></div>
<div class="button sliderbtns" data-sc="2"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
javascript
$( ".sliderbtns" ).click(function() {
var button_data = $(this).attr('data-sc');
myslider(button_data);
});
Run Code Online (Sandbox Code Playgroud)
js中的函数
function myslider(position) {
if (position == "next" && (currentslide == slidecount)) {
position = 1;
} else if (position == "next") {
position = currentslide + 1;
} else if ((position == "prev") && (currentslide == 1)){
position = slidecount;
} else if ((position …Run Code Online (Sandbox Code Playgroud)