Closed robksawyer closed 11 years ago
Update: I tried moving SitemapController to app/Controller/ and now I'm getting the following:
Component class FilterResultsComponent could not be found.
Got it working, but now I'm confused why it's not loading the routes.php from the Plugin.
Moved the _generateSitemap logic to each model instead of each controller. And had to update the SitemapController to the following:
/**
* Loop through active models and generate sitemap data.
*/
public function index() {
$models = App::objects('Model');
$sitemap = array();
// Fetch sitemap data
foreach ($models as $model) {
// Don't load AppModel's, Model's who can't be found
if ( strpos($model, 'AppModel') !== false ) {
continue;
}
$instance = ClassRegistry::init($model);
if ( method_exists($instance, '_generateSitemap') ) {
if ($data = $instance->_generateSitemap()) {
$sitemap = array_merge($sitemap, $data);
}
}
}
// Cleanup sitemap
if ($sitemap) {
foreach ($sitemap as &$item) {
if (is_array($item['loc'])) {
if (!isset($item['loc']['plugin'])) {
$item['loc']['plugin'] = false;
}
$item['loc'] = h(Router::url($item['loc'], true));
}
if (array_key_exists('lastmod', $item)) {
if (!$item['lastmod']) {
unset($item['lastmod']);
} else {
$item['lastmod'] = CakeTime::format(DateTime::W3C, $item['lastmod']);
}
}
}
}
// Render view and don't use specific view engines
$this->RequestHandler->respondAs($this->request->params['ext']);
$this->set('sitemap', $sitemap);
}
Updated the routes to and had to add them to the main app/Config/routes.php (Not loading from Plugin)
Router::connect('/sitemap', array('plugin' => 'utility', 'controller' => 'sitemap', 'action' => 'index', 'ext' => 'xml'));
Router::connect('/sitemap', array('plugin' => 'utility', 'controller' => 'sitemap', 'action' => 'index', 'ext' => 'json'));
FilterResultsComponent
is. Is that something of yours?Also, what CakePHP version?
Seems something changed in Cake routes, updated with changes.
When I navigate to
http://mysite.com/sitemap.xml
, I'm getting the following error.For example: I've added the following to a controller.
And I've added the following to my bootstrap.
Notes: I am using a custom Authenticate method for Auth and was thinking that this was having some effect on it, but still not sure.