Danke. Die meisten hab ich glaube ich schon probiert.
Mein Problem ist folgendes:
Ich möchte in der Kategorie "NEWS" im Startartikel alle Artikel dieser Kategorie anteasern. Dafür verwende ich folgendes Modul:
Ausgabe
- Code: Alles auswählen
<?php
$itemsPerSide = "REX_VALUE[1]";
$wordsPerArticle = "REX_VALUE[2]";
$articles = "REX_VALUE[3]";
if (!$REX['REDAXO']) {
// Sortierfunktion
if(!function_exists("sortArticlesByREX_VALUE[4]REX_VALUE[5]")) {
function sortArticlesByREX_VALUE[4]REX_VALUE[5]( $artA, $artB) {
$sortby = 'REX_VALUE[4]';
$createA = $artA->getValue($sortby);
$createB = $artB->getValue($sortby);
if ( $createA == $createB) {
return 0;
}
if('REX_VALUE[5]') return $createA > $createB ? -1 : 1;
else return $createA < $createB ? -1 : 1;
}
}
$start = !empty($_GET['start']) ? (int) $_GET['start'] : 0; // Startitem
$offset = $itemsPerSide; // 10 Items pro Seite
$cats = array( $articles); // alle Kategorien die Du "indizieren" willst
$articles = array();
foreach ( $cats as $catId) {
$cat = OOCategory::getCategoryById( $catId);
// CatIds die nicht funktionieren aussortieren
if( $cat === null) {
continue;
}
$cat_articles = $cat->getArticles( true);
foreach ( $cat_articles as $ooarticle) {
// keine Startartikel anzeigen
if ( $ooarticle->isStartPage()) {
continue;
}
// Damit keine Endlosschleife passiert, den Artikel der die Pagination setzt ¸berspringen
if ( $ooarticle->getId() == REX_ARTICLE_ID) {
continue;
}
$articles[] = $ooarticle;
}
}
$articles_length = count( $articles);
// Sortieren
if ( $articles_length > 0) {
usort( $articles, "sortArticlesByREX_VALUE[4]REX_VALUE[5]");
}
$article_list = array_slice( $articles, $start, $offset);
foreach ( $article_list as $ooarticle) {
if ($ooarticle->isOnline(true)) {
$articleId = $ooarticle->getId();
$article = new article();
$article->setArticleId( $articleId);
$articleContent = $article->getArticle();
// Leerzeichen entfernen am Anfang und Ende des Strings
$articleContent = trim($articleContent);
// Leerzeichen vor </p> einfuegen.
// Sonst wird das letzte Wort eines Absatzes und das erste Wort
// des nachfolgenden Absatzes als ein Wort erkannt
$articleContent = str_replace("</p>", " </p>", $articleContent);
// Leerzeichen vor <br /> einfuegen.
// Sonst wird das letzte Wort einer Zeile und das erste Wort
// des nachfolgenden Zeile als ein Wort erkannt
$articleContent = str_replace("<br />", " <br />", $articleContent);
$output = "";
$words = explode(" ",$articleContent);
$wordsCount = count($words);
//$wordsCount = str_word_count($articleContent);
if ($wordsCount < $wordsPerArticle) $wEnd = $wordsCount;
else $wEnd = $wordsPerArticle;
for ($w=0;$w<$wEnd;$w++) {
$output .= $words[$w]." ";
}
// Leerzeichen entfernen am Anfang und Ende des Strings
$output = trim($output);
$isCloseParagraph = substr($output,-4);
// opened & closed TDs/TRs/TABLEs zählen und ggf. closing Tags ergänzen
$openedTDs = substr_count($output, '<td');
$closedTDs = substr_count($output, '</td>');
$countmissingTDs = $openedTDs - $closedTDs;
if ($openedTDs > $closedTDs) {
while ($countmissingTDs > 0):
$output .= "</td>";
$countmissingTDs = $countmissingTDs - 1;
endwhile;
}
$openedTRs = substr_count($output, '<tr');
$closedTRs = substr_count($output, '</tr>');
$countmissingTRs = $openedTRs - $closedTRs;
if ($openedTRs > $closedTRs) {
while ($countmissingTRs > 0):
$output .= "</tr>";
$countmissingTRs = $countmissingTRs - 1;
endwhile;
}
$openedTABLEs = substr_count($output, '<table');
$closedTABLEs = substr_count($output, '</table>');
$countmissingTABLEs = $openedTABLEs - $closedTABLEs;
if ($openedTABLEs > $closedTABLEs) {
while ($countmissingTABLEs > 0):
$output .= "</table>";
$countmissingTABLEs = $countmissingTABLEs - 1;
endwhile;
}
$link = ' <a href="'.rex_getUrl($articleId).'">...mehr »</a>';
$newString = $link.'</p>';
if ($isCloseParagraph == '</p>') {
$output = substr_replace($output,$newString,-4);
}
else {
$output .= $newString;
}
// opened & closed DIVs/SPANs zählen und ggf. closing Tags ergänzen
$openedSPANs = substr_count($output, '<span');
$closedSPANs = substr_count($output, '</span>');
$countmissingSPANs = $openedSPANs - $closedSPANs;
if ($openedSPANs > $closedSPANs) {
while ($countmissingSPANs > 0):
$output .= "</span>";
$countmissingSPANs = $countmissingSPANs - 1;
endwhile;
}
$openedDIVs = substr_count($output, '<div');
$closedDIVs = substr_count($output, '</div>');
$countmissingDIVs = $openedDIVs - $closedDIVs;
if ($openedDIVs > $closedDIVs) {
while ($countmissingDIVs > 0):
$output .= "</div>";
$countmissingDIVs = $countmissingDIVs - 1;
endwhile;
}
print '<div>'.$output.'</div>';
}
}
$prevStart = $start - $offset;
if ( $prevStart < 0)
{
$prevStart = '';
}
$nextStart = $start + $offset;
if ( $nextStart >= $articles_length)
{
$nextStart = '';
}
$link_format = '<a href="index.php?article_id=REX_ARTICLE_ID&start=%s">%s</a>';
// Vorherige Seite Link
if ( $prevStart !== '') {
$backLink = sprintf( $link_format, $prevStart, '« vorherige Seite');
}
// Nächste Seite Link
if ( $nextStart !== '') {
$nextLink = sprintf( $link_format, $nextStart, 'nächste Seite »');
}
if ($backLink != "" AND $nextLink != "") {
print '<div>'.$backLink.' | '.$nextLink.'</div>';
}
elseif ($nextLink != "") {
print '<div>'.$nextLink.'</div>';
}
elseif ($backLink != "") {
print '<div>'.$backLink.'</div>';
}
}
else {
echo "Anzahl der News pro Seite: REX_VALUE[1]<br />Anzahl der Wörter pro Newsartikel: REX_VALUE[2]<br />Kategorie: REX_VALUE[3]";
}
?>
Leider werden mir aber alle Spalten ausgegeben. Ich möchte aber lediglich die Content-Spalte anzeigen lassen.