Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Cycle through a Class

Ok this is class that render's a nugget
class Display_Nugget extends Control { function Display_Nugget(&$Context) { $this->Name = 'Display_Nugget'; $this->Control($Context); } function Render() { global $NuggetMng; echo '<div class="Nugget" >'.$NuggetMng->Nugget[2]['html'].'</div>'; } }

This is where it is called
if (in_array($Context->SelfUrl, array('index.php', 'account.php', 'categories.php', 'comments.php', 'post.php', 'search.php', 'settings.php', 'extension.php'))) { $New_Display_Nugget = new Display_Nugget($Context); $Page->AddRenderControl($New_Display_Nugget,$Configuration[$NuggetMng->Nugget[2]['position']]+$NuggetMng->Nugget[2]['weight']); }
This is how the Array looks like
$NuggetMng->Nugget = array( 0 => array( 'html' =>'This is where ur content will appear', 'position' => 'CONTROL_POSITION_HEAD', 'weight' => 10), 1 => array( 'html' => 'This is where ur content will appear', 'position' => 'CONTROL_POSITION_HEAD', 'weight' => 6 ));

Now how do I cycle throw, so I go through all of the Array.


thanks in advance

Comments

  • function Render() { global $NuggetMng; while(list($a, $b) = each($NuggetMng->Nugget)) { echo '<div class="Nugget" >'.$b['html'].'</div>'; } }

    That help?
  • edited March 2007
    not like that
    I tried this
    class Display_Nugget extends Control { function Display_Nugget(&$Context) { $this->Name = 'Display_Nugget'; $this->Control($Context); } function Display_Nugget_Html ($i) { global $NuggetMng; echo ('<div class="Nugget">'. $NuggetMng->Nugget[$i]['html'].'</div>'); } } if (in_array($Context->SelfUrl, array('index.php', 'account.php', 'categories.php', 'comments.php', 'post.php', 'search.php', 'settings.php', 'extension.php'))) { $New_Display_Nugget = new Display_Nugget($Context); for($i = 0; $i < count($NuggetMng->Nugget); $i++){ $Page->AddRenderControl($New_Display_Nugget->Display_Nugget_Html($i),$Configuration[$NuggetMng->Nugget[$i]['position']]+$NuggetMng->Nugget[$i]['weight']); } }
    It does cycle through but only displays the nuggets and gets ride of the actual page. So its a blank page with just the nuggets.
    something is wrong with this
    Picture 1

    It prolly because I'm using $New_Display_Nugget->Display_Nugget_Html($i) for the render control instead of $New_Display_Nugget
  • why not just make a new class instance on every iteration?
  • Dinoboff helped out and it works. :) I can email you the whole extension if you whisper me your email
This discussion has been closed.