Cupara
Well-known member
Ok this is odd, haven't gotten this error ever and I can not figure it out.
Here is the error:
Model File: LatestThreads.php
Pulling data in ControllerPublic/Index.php:
ViewPublic/Portal.php file:
Might be a bit of info but giving all info I think would help in determining the issue.
Here is the error:
Template Errors: xportal_latest_threads
- Invalid argument supplied for foreach() in C:\Program Files (x86)\Zend\Apache2\htdocs\xenforo\library\XenForo\Template\Abstract.php(208) : eval()'d code, line 6:
5: ';
6: foreach ($t AS $i)
7: {
Model File: LatestThreads.php
PHP:
class xPortal_Model_LatestThreads extends XenForo_Model
{
public function getThreads($id)
{
$ltOption = XenForo_Application::get('options')->xportal_latestThreads;
$lThreads = $this->limitQueryResults('
SELECT thread_id, title, user_id, username, post_date, last_post_user_id, last_post_username
FROM xf_thread WHERE node_id = ' . $ltOption . ' ORDER BY thread_id ', 5);
return $this->_getDb()->fetchAll($lThreads);
}
}
Pulling data in ControllerPublic/Index.php:
PHP:
$xpThreadModel = $this->getModelFromCache('xPortal_Model_LatestThreads');
$t = $xpThreadModel->getThreads(5);
$viewParams = array(
't' => $t
);
return $this->responseView('xPortal_ViewPublic_Portal', 'xportal_index', $viewParams);
ViewPublic/Portal.php file:
PHP:
class xPortal_ViewPublic_Portal extends XenForo_ViewPublic_Base
{
public function renderHtml()
{
$blocksModel = new xPortal_Model_Blocks;
$left = $blocksModel->getLeft();
$mid = $blocksModel->getMid();
$right = $blocksModel->getRight();
$leftBlocks = "";
foreach ($left AS $lft)
{
$leftTemplate = $lft['temp_template'];
$leftBlocks .= $this->createTemplateObject($leftTemplate);
}
$this->_params['leftBlocks'] = $leftBlocks;
$midBlocks = "";
foreach ($mid AS $m)
{
$midTemplate = $m['temp_template'];
$midBlocks .= $this->createTemplateObject($midTemplate);
}
$this->_params['midBlocks'] = $midBlocks;
$rightBlocks = "";
foreach ($right AS $rgt)
{
$rightTemplate = $rgt['temp_template'];
$rightBlocks .= $this->createTemplateObject($rightTemplate);
}
$this->_params['rightBlocks'] = $rightBlocks;
}
}
Might be a bit of info but giving all info I think would help in determining the issue.