package back import ( "html/template" "strconv" ) func getNewsByPage(page int) template.HTML { tNews := template.HTML("") news := material{} news.Category = "новость" e := news.Select(page*8, 8) if e != nil { logger.Println(e.Error()) return tNews } for i, m := range news.Rows { images := `
` if m.Image.Valid { images = `
` } if i == 0 || i == 3 || i == 4 || i == 7 || i == 8 { tNews += template.HTML(`
` + m.Caption + `
` + m.Preview.String + `
Читать далее` + images + `
`) } else { tNews += template.HTML(`
` + m.Caption + `
` + m.Preview.String + `
Читать далее
`) } } return tNews } func getNewsPaginationByPage(page int) template.HTML { tNewsPagination := template.HTML("") news := material{} news.Category = "новость" count, e := news.SelectCount() if e != nil { logger.Println(e.Error()) return tNewsPagination } count = count / 8 if count%8 != 0 { count++ } for i := 0; i < count; i++ { if i == page { tNewsPagination += template.HTML(`` + strconv.Itoa(i+1) + ``) } else { tNewsPagination += template.HTML(`` + strconv.Itoa(i+1) + ``) } } return tNewsPagination }