Author Topic: Smarty array loop problem.  (Read 1186 times)

0 Members and 1 Guest are viewing this topic.

Offline BooherTopic starter

  • Irregular
  • Posts: 2
    • View Profile
Smarty array loop problem.
« on: April 17, 2010, 05:52:15 PM »
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
Code: [Select]
<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:
Code: [Select]
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:

Offline TeddyKiller

  • Devotee
  • Posts: 1,055
  • Gender: Male
  • What is today without tomorrow or yesterday?
    • View Profile
Re: Smarty array loop problem.
« Reply #1 on: April 17, 2010, 08:21:18 PM »
I dont recommend displaying big images on a thread. It just messes up. I don't know whats wrong or anything.. but was only just telling you :) What's tidier, is easier for people to read. Keep that in mind :)
Please use [code][/code] and [php][/php] when posting code.

Please use proper PHP opening tags. <?php code here ?>

If I have posted false information, feel free to correct me.

Offline dotMoe

  • Irregular
  • Posts: 14
  • Gender: Male
  • ... coming to a server near you ...
    • View Profile
    • dotMoe
Re: Smarty array loop problem.
« Reply #2 on: April 19, 2010, 02:25:45 AM »
Hey,
Your issue is simple:

Instead of $plugin->author.

its $plugin.author
$pluging.description

in the tpl file.

Offline BooherTopic starter

  • Irregular
  • Posts: 2
    • View Profile
Re: Smarty array loop problem.
« Reply #3 on: April 19, 2010, 03:11:09 PM »
omg. thank you soo much. i coulda swore you was suppost to use -> :S lol.