Okay... thanks for reply.
I tried to clean the whole mess up and this is the result:
Controller-method:
PHP Code:
[...]
if (is_null($year) && $menuIndex === 2) {
for ($cyear = (int) date('Y'); $cyear >= $this->config->item('cat_show_til_year'); $cyear --) {
$this->data['articles'][$cyear] = $this->getArticles($this->site->getArticlesByCat($category, $menuIndex, $cyear, 8));
}
$this->data['show_years'] = true;
} elseif (! is_null($year) && $menuIndex === 2) {
$this->data['articles'][$year] = $this->getArticles($this->site->getArticlesByCat($category, $menuIndex, $year));
$this->data['site_title'] .= ' > ' . $year;
} else {
$this->data['articles'][] = $this->getArticles($this->site->getArticlesByCat($category, $menuIndex));
}
[...]
the getArticle-method (before: getCategoryPageString()):
PHP Code:
private function getArticles($result)
{
if (count($result) === 0)
return array();
$pages = array();
foreach ($result as $page) {
$img_thumb = parse_url(img_url() . 'akt/' . $page->beiName . '/thumbnail.jpg')['path'];
if (! file_exists(ltrim($img_thumb, '/'))) {
$img_thumb = img_url() . 'article_img.png';
}
$pages[$page->beiName] = array(
'img' => $img_thumb,
'title' => $page->beiTitel,
'content' => $page->beiInhalt
);
}
return $pages;
}
and finally a part of my view:
PHP Code:
[...]
<?php foreach($articles as $year => $article): ?>
<?php if($show_years): ?>
<h2 class="cat_year">
<a href="/category/search/<?=$category?>/<?=$year?>"><?=$year?></a>
</h2>
<?php endif; ?>
<?php foreach($article as $name => $content): ?>
<article class="cat_container">
<header class="cat_header">
<h2 class="hidden">Kategorie</h2>
<img src="<?=$content['img']?>" alt="<?=$content['title']?>" title="<?=$content['title']?>">
</header>
<div class="cat_body">
<h2>
<a href="/page/show/<?=$name?>"><?=$content['title']?></a>
</h2>
<p><?=character_limiter(strip_tags($content['content']), 130, '...')?></p>
</div>
</article>
<?php endforeach; ?>
<?php endforeach; ?>
[...]
This is much better and the view is well-feed. Is this the way to go? (sry for asking so often, but I would like to get the whole view thing, because, at least I think, it's hard to seperate :/)
Quote:The PHP alternate syntax I used in the second example may seem verbose at first, but it results in view files that are easier to read and that generate cleaner HTML without having to include a bunch of "\n" and "\t" in your strings.
Hihi.. even if a lot of people don't like this syntax, I really do when working with mixed html/php files.
-.-.-.-.-.-.-.-.-
-.-.-.-.-.-.-.-.-