I have site with subdomains (news.site.com, events.site.com etc). i am added to config my custom url rule, who find by requested url article in DB and call article controller with action show
for example: 'http://ift.tt/2cCDF6Y' i want find in db article with url = 'some-article-with-custom-url' and call actionShow() in ArticleController
but on news.site.com and events.site.com i want find articles with different site_id (column in db)
news.site.com - 'select * from article where site_id = 1 ...' events.site.com - 'select * from article where site_id = 2 ...'
where i can init some subdomains settings, if on UrlManager level i must have algready have this settings?
'urlManager' => [
'rules' = [
...
[
'class' => 'common\components\ArticleUrlRule'
],
]
]
implementation of parse req of this class:
public function parseRequest($manager, $request) { $articleId = Article::getArticleIdByUrl($request->pathInfo);
if ( !empty($articleId) ) {
return [
'article/show',
[
'id' => $articleId
]
];
}
return false;
}
Aucun commentaire:
Enregistrer un commentaire