根据页面获取seo @param page 页面标识 @param defSeo 默认的seo的map,必须有title、keywords和description字段
(page string, defSeo map[string]string)
| 288 | // @param page 页面标识 |
| 289 | // @param defSeo 默认的seo的map,必须有title、keywords和description字段 |
| 290 | func (this *BaseController) GetSeoByPage(page string, defSeo map[string]string) { |
| 291 | var seo models.Seo |
| 292 | |
| 293 | orm.NewOrm().QueryTable(models.TableSeo).Filter("Page", page).One(&seo) |
| 294 | defSeo["sitename"] = this.Sitename |
| 295 | if seo.Id > 0 { |
| 296 | for k, v := range defSeo { |
| 297 | seo.Title = strings.Replace(seo.Title, fmt.Sprintf("{%v}", k), v, -1) |
| 298 | seo.Keywords = strings.Replace(seo.Keywords, fmt.Sprintf("{%v}", k), v, -1) |
| 299 | seo.Description = strings.Replace(seo.Description, fmt.Sprintf("{%v}", k), v, -1) |
| 300 | } |
| 301 | } |
| 302 | this.Data["SeoTitle"] = seo.Title |
| 303 | this.Data["SeoKeywords"] = seo.Keywords |
| 304 | this.Data["SeoDescription"] = seo.Description |
| 305 | } |
| 306 | |
| 307 | // 站点地图 |
| 308 | func (this *BaseController) Sitemap() { |
no test coverage detected