{if $item->kind == "folder"} {if $item->folderCount > 0 || $item->fileCount > 0} onclick="JavaScript:return confirm('This folder is not empty. If you delete it all content will also be deleted. Do you still want to continue?');"><img src="/Images/iconset/cross.png" width="16px" title="delete"></a></p></td>
{else} onclick="JavaScript:return confirm('Do you really want to delete this folder?');"><img src="/Images/iconset/cross.png" width="16px" title="delete"></a></p></td> {/if} {elseif $item->kind == "file"}
<td class="remove"><p><a href="/Views/Files/Delete/{$item->id}" onclick="JavaScript:return confirm('Do you really want to delete this file?');"><img src="/Images/iconset/cross.png" width="16px"/ title="delete"></a></p></td>
在我看来,上面的方面只能是一次性的传送。但在我的表格中每条记录是不停的循环并且显示的,如果我要把前端每次循环的关键变量id传送到后端进行处理,那又应该如何做呢?
与该smarty相对应的后端php 代码为:(我已经尽量加注释了)<?php
load_module("folders");
load_module("files");
//该页面的基本功能就是在表格中显示某个区域里的文件或者文件夹,我要增加一个链接link,并且其他一些链接等功能
$id = getParamStr("id"); //此处id应该是这表格所属区域的Id,与我的问题相联系的数据库中储存的文件或链接id不一样,这个是我的理解,我也是刚看这代码
if ($action == "search") //对这个页面有两个动作,一个是search
{
$search = postParamStr("search");
$folders = do_action("folders","search", array($search, $currentUser->allowedRegion));
$files = do_action("files","search", array($search, $currentUser->allowedRegion));
$smarty->assign("folder", NULL);
$paths = array("Search Result");
$path = new stdClass();
$path->id = NULL;
$path->name = "Search Result";
$smarty->assign("paths", array($path));
}
else //对这个页面的另一动作是正常显示
{
$folders = list_items("folders", $id);
$folder = get_item("folders", $id);
$files = list_items("files", $id);
$smarty->assign("folder",$folder);
$paths = $folder->path;
if ($currentUser->level == 2)
{
unset($paths[0]);
$paths = array_values($paths);
}
$smarty->assign("paths", $paths);
}$items = array_merge($folders,$files); //获取到显示记录,并把多个记录组合起来
$items = sort_items($items); //排序功能
$smarty->assign("items", $items);
$smarty->assign("action", $action);
$smarty->display("folders.tpl");
?>
前端的代码太多,我还是截取循环的那部分,供参考:{if count($items) > 0}
{foreach $items as $item}
{strip}
<tr class="light" style="display:table-row;border-bottom:1px solid #DADAE3;" id="{$item->id}">
{if $item->kind == "folder"}
<td class="type"><p><img src="/Images/iconset/Folder2.png" title="folder"/></p></td>
{else}
{if $item->type == "docx" || $item->type == "doc"}
<td class="type"><p><img src="/Images/iconset/page_white_word.png" title="word document"/></p></td>
{else if $item->type == "xlsx" || $item->type == "xls"}
<td class="type"><p><img src="/Images/iconset/page_white_excel.png" title="excel document"/></p></td>
{elseif $item->type == "pdf"}
<td class="type"><p><img src="/Images/iconset/page_white_acrobat.png" title="PDF"/></p></td>
{elseif $item->type == "png" || $item->type == "gif" || $item->type == "jpg"}
<td class="type"><p><img src="/Images/iconset/picture.png" title="png"/></p></td>
{elseif $item->type == "ppt" || $item->type == "pptx"}
<td class="type"><p><img src="/Images/iconset/page_white_powerpoint.png" title="powerpoint document"/></p></td>
{elseif $item->type == "mp4"}
<td class="type"><p><img src="/Images/iconset/film.png" title="movie"/></p></td>
{elseif $item->type == "link"}
<td class="type"><p><img src="/Images/iconset/link.png" title="link"/></p></td>
{else}
<td class="type"><p><img src="/Images/iconset/page_white.png" title="document"/></p></td>
{/if}
{/if}
{if $item->kind == "folder"}
<td class="name"><p><a href="/Views/Regions/{$item->id}">{$item->name}</a></p></td>
{elseif $item->type != "link"}
<td class="name"><p><a href="/Regions/Files/Download/{$item->id}">{$item->name}</a></p></td>
{else}
{$link_content=""}
{$this_id=$item->id}
{$search_link_query="select * from archive.file where id='$this_id'"}
{$con = mysqli_connect("localhost","root","goldmine")}
{$result = mysqli_query($con,$search_link_query)}
{mysqli_close($con)}
{$row=mysqli_fetch_row($result)}
{$link_content=$row[8]}
<td class="name"><p><a href="{$link_content}" target="_blank">{$item->name}</a></p></td>
{/if}
<td class="creator"><p>{$item->createdByName}</p></td>
<td class="created"><p>{$item->created}</p></td>
<td class="modified"><p>{$item->lastUpdated}</p></td>
<td class="visibility"><p>Visible</p></td>
<td class="size"><p>{if $item->size > 1000}
{round(($item->size / 1024), 1)}MB
{else}
{$item->size}KB</p></td>
{/if}</p></td>
{if $item->kind == "folder"}
<td class="id" align="middle"><p><a href="JavaScript:void(0);" onclick="return popitup('/Views/Folders/{$item->id}/Move')"><img src="/Images/iconset/move.png" style="width:18px;" /></a></p></td>
{elseif $item->kind == "file"}
<td class="id" align="middle"><p><a href="JavaScript:void(0);" onclick="return popitup('/Views/Files/{$item->id}/Move')"><img src="/Images/iconset/move.png" style="width:18px;" /></a></p></td>
{/if}
{if $item->kind == "folder"}
<td class="edit"><p><a href="/Views/Folders/Edit/{$item->id}"><img src="/Images/iconset/wrench2.png" width="16px" title="edit"/></a></p></td>
{elseif $item->kind == "file"}
<td class="edit"><p><a href="/Views/Files/Edit/{$item->id}"><img src="/Images/iconset/wrench2.png" width="16px" title="edit"/></a></p></td>
{/if}
<td class="remove"><p><a href="/Views/Folders/Delete/{$item->id}"
{if $item->kind == "folder"}
{if $item->folderCount > 0 || $item->fileCount > 0}
onclick="JavaScript:return confirm('This folder is not empty. If you delete it all content will also be deleted. Do you still want to continue?');"><img src="/Images/iconset/cross.png" width="16px" title="delete"></a></p></td>
{else}
onclick="JavaScript:return confirm('Do you really want to delete this folder?');"><img src="/Images/iconset/cross.png" width="16px" title="delete"></a></p></td>
{/if}
{elseif $item->kind == "file"}
<td class="remove"><p><a href="/Views/Files/Delete/{$item->id}" onclick="JavaScript:return confirm('Do you really want to delete this file?');"><img src="/Images/iconset/cross.png" width="16px"/ title="delete"></a></p></td>
{/if}
</tr>
{/strip}
{/foreach}
{else}
<tr><td colspan="10"><table>
<tr valign="middle" >
<td class="light">
{if $action != "search"}
<img src="/Images/emptyfolder.png" width="130px"/>
{/if}
</td>
<td class="light">
{if $action == "search"}
<br />
<h1>No files or folders could be found!</h1>
{else}
<h1>This folder is empty!</h1>
{/if}
1. 在smarty模板中,怎么{$con = mysqli_connect("localhost","root","root")}就会产生这么多的“1”呢?表明连接数据库成功么?有无方法隐藏这个显示?2.smarty模板中前端的循环,如果与后端php代码处理动态的进行数值传输呢?
我需要把每次循环中的关键变量传到后端,经过处理后又把结果返回该循环中呢,并且在该次循环中显示php传送过来的值。如果做到呢?大神们,你们有办法解决么?希望给出代码示例,否则小弟不会做啊。谢谢啊。
//该页面的基本功能就是在表格中显示某个区域里的文件或者文件夹,除文件和文件夹类型外我要增加一个类型:链接link,并且还增加其他一些与link链接这种类型相关的功能
多次测试后,发现是{mysqli_close($con)}这句话产生了“1”,其结果为
那就把 {mysqli_close($con)} 删掉