Hi guys, me again.
Just trying to learn some stuff to build a very, very simple article display system.
What I have got is the following directory structure for my application;
Homepage
- ControllerPublic
- Index.php
- Model
- Home.php
- Route
- Prefix
-Index.php
In my ControllerPublic/Index.php file I have;
	
	
	
		
In my Model/Home.php file I have;
	
	
	
		
and in my route/prefix/index.php file I have;
	
	
	
		
What I am trying to do, is when navigating to the url /home/ I select some articles from a database and pass them to a template for display.
I have the database setup correctly for this.
If I remove the code from ControllerPublic/Index.php and just display;
	
	
	
		
My template Article_index displays no problem.
But as soon as I try and call the model, I get the following error;
Just hoping someone can point me in the right direction here, as I am stumped. I assume i'm not calling the model correctly, which means its not looking in the right place for it. But, I am unsure as to where to go from here.
Thanks for any help anybody can offer.
Regards,
Lee
				
			Just trying to learn some stuff to build a very, very simple article display system.
What I have got is the following directory structure for my application;
Homepage
- ControllerPublic
- Index.php
- Model
- Home.php
- Route
- Prefix
-Index.php
In my ControllerPublic/Index.php file I have;
		PHP:
	
	<?php
class Homepage_ControllerPublic_Index extends XenForo_ControllerPublic_Abstract
{
    public function actionIndex()
    {
        // Get the model class for the homepage
        $homeModel = $this->getHomeModel();
        // Set the maximum amount of articles required - commented out as I haven't setup the option yet.
        // $maxArticles = XenForo_Application::get('options')->ArticleMax;
        // Get the latest articles
        $latestArticles = $this->getLatestArticles($maxArticles);
        // read the date of the most recent note
        if ($latestArticles)
        {
            $date = $latestArticles[0]['post_date'];
        }
        else
        {
            $date = 0;
        }
        // put the data into an array to be passed to the view so the template can use it
        $viewParams = array(
            'articles' => $articles,
            'date' => $date
        );
        // return a View (Article_ViewPublic_Index) using template 'Article_index'
        return $this->responseView(
            'Hpmepage_ViewPublic_Index',
            'Article_index',
            $viewParams
        );
 
    }
}In my Model/Home.php file I have;
		PHP:
	
	<?php
class Homepage_Model_Home extends XenForo_Model
{
    public function getLatestArticles($maxArticles = 0)
    {
        $sql = '
            SELECT
                articles.*,
                user.*
            FROM xf_articles AS articles
            LEFT JOIN xf_user AS user
            ORDER BY post_date DESC
        ';
        // ensure we have a meaningful value for $maxArticles
        if ($maxArticles = max($maxArticles, 0))
        {
            // build our LIMIT (or equivalent) clause
            $sql = $this->limitQueryResults($sql, $maxArticles);
        }
        return $this->_getDb()->fetchAll($sql);
    }
}and in my route/prefix/index.php file I have;
		PHP:
	
	<?php
class Homepage_Route_Prefix_Index implements XenForo_Route_Interface
{
    /**
    * Match a specific route for an already matched prefix.
    *
    * @see XenForo_Route_Interface::match()
    */
    public function match($routePath, Zend_Controller_Request_Http $request, XenForo_Router $router)
    {
        return $router->getRouteMatch('Homepage_ControllerPublic_Index', $routePath);
    }
}What I am trying to do, is when navigating to the url /home/ I select some articles from a database and pass them to a template for display.
I have the database setup correctly for this.
If I remove the code from ControllerPublic/Index.php and just display;
		PHP:
	
	<?php
class Homepage_ControllerPublic_Index extends XenForo_ControllerPublic_Abstract
{
    public function actionIndex()
    {
        // return a View (Article_ViewPublic_Index) using template 'Article_index'
        return $this->responseView(
            'Hpmepage_ViewPublic_Index',
            'Article_index'
        );
 
    }
}My template Article_index displays no problem.
But as soon as I try and call the model, I get the following error;
Fatal error: Call to undefined method Homepage_ControllerPublic_Index::getHomeModel() in /Users/leerobson/Sites/dev/library/Homepage/ControllerPublic/Index.php on line 9
Just hoping someone can point me in the right direction here, as I am stumped. I assume i'm not calling the model correctly, which means its not looking in the right place for it. But, I am unsure as to where to go from here.
Thanks for any help anybody can offer.
Regards,
Lee

 
 
		 
 
		
 
 
		 
 
		