Jump to content

Smarty array loop problem.


Booher

Recommended Posts

It is looping the rows correctly, but not adding the variables.:S

 

admin/plugins.php:

<?php
define("requireLogin",1);
define("requireAdmin",1);
require("../global.php");
switch($_GET['act']){
default:
	$core->template->display("header.tpl");
	$query = array(
		"SELECT"	=> "*",
		"FROM"		=> "plugins",
	);
	$result = $core->db->query_build($query) or error(__FILE__, __LINE__);

	$plugins = array();
	while($p=$core->db->fetch_assoc($result)){
		$plugins[] = $p;
	}
	$core->template->assign("plugins",$plugins);
	$core->template->display("adminplugin_home.tpl");
	$core->template->display("footer.tpl");
	break;
}
?>

 

styles/default/templates/adminplugin_home.tpl

			<table width="90%" border="1" align="center">
			<tr>
				<th width="50%">Plugin Name</th>
				<th>Actions</th>
			</tr>
			<tr>
				<td colspan="100%">Installed plugins</td>
			</tr>
			{foreach from=$plugins item=plugin}
				<tr>
					<td valign="top">
						{$plugin->title}<br/>
						<b>Made By:</b>{$plugin->author}<hr/>
						{$plugin->description}
					</td>
					<td valign="top">
						<a href="{$URL}admin/plugins.php?act=uninstall&id={$plugin->id}">Uninstall</a>
					</td>
				</tr>
			{/foreach}
		</table>

print_r on $plugins returns:

Array ( [0] => Array ( [id] => test [title] => Test [version] => 1.0.0 [description] => Test Plugin [author] => booher [uninstall] => [uninstall_note] => [disabled] => 0 ) )  

Here is the output:

aourtk.jpg

Link to comment
https://forums.phpfreaks.com/topic/198880-smarty-array-loop-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.