[GELÖST] Problem mit News-Modul

Gesperrt
onda88
Beiträge: 77
Registriert: Di 28. Okt 2008, 16:41
Kontaktdaten:

[GELÖST] Problem mit News-Modul

Beitrag von onda88 »

Hallo Leude!
Ich hab da ein Problem mit dem News-Modul und zwar zeigt er mir die Headline einmal als Headline und darunter nocheinmal als Content an. Möchte aber gern das er mir nur die Headline einmal als diese anzeigt.
Der link zu Seite: http://30114.web.zcom.it/cms/front_content.php?idcat=4, die News (und das Problem) sind rechts unter dem Logo.

Der Modul-Code:
input:

Code: Alles auswählen

?><?php
/**
* $RCSfile$
*
* Description: Newslist / ArticleList. Module "Input".
*
* @version 1.0.0
* @author Andreas Lindner
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2005-08-12
* }}
*
* $Id$
*/

#Select category
$cms_idcat = "CMS_VALUE[1]";

echo '<table cellpadding="0" cellspacing="0" border="0">';

echo '
        <tr><td class="text_medium" style="padding:5px">Kategorie w&auml;hlen: </td></tr>
        <tr><td class="text_medium" style="padding:5px">';

echo buildCategorySelect("CMS_VAR[1]", "CMS_VALUE[1]");
echo '&nbsp;<input type="image" src="images/submit.gif">';

echo '</td></tr>';

#Select sort field and sort order
$sortdate = 'checked';
$cms_imgsize = "CMS_VALUE[14]";
$cms_limit_articles = "CMS_VALUE[15]";
$cms_sort_direction = "CMS_VALUE[16]";
if ("CMS_VALUE[17]" != '') {
    $cms_include_start_article = ' checked';
} else {
    $cms_include_start_article = '';
}

if ("CMS_VALUE[3]" == 'sortdate') {
    $sortdate = 'checked';
    $sortnum = '';
}
elseif ("CMS_VALUE[3]" == 'sortnum') {
    $sortdate = '';
    $sortnum = 'checked';
}

echo '
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung nach Datum").':</td>
          <td style="padding:5px;"><input type="radio" name="CMS_VAR[3]" value="sortdate" '.$sortdate.'></td>
        </tr>
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung nach Nummer").':</td>
          <td style="padding:5px;"><input type="radio" name="CMS_VAR[3]" value="sortnum" '.$sortnum.'></td>
        </tr>
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung aufsteigend").':</td>
          <td style="padding:5px;">';
if (strtolower($cms_sort_direction) == 'desc') {
    echo '<input type="radio" name="CMS_VAR[16]" value="asc"/>';
} else {
    echo '<input type="radio" name="CMS_VAR[16]" value="asc" checked/>';
}
echo '</td>
        </tr>
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Sortierung absteigend").':</td>
          <td style="padding:5px;">';
if (strtolower($cms_sort_direction) == 'desc') {
    echo '<input type="radio" name="CMS_VAR[16]" value="desc" checked/>';
} else {
    echo '<input type="radio" name="CMS_VAR[16]" value="desc"/>';
}
echo '</td>
        </tr>';

$noimg = '';
if ("CMS_VALUE[13]" == 'true') {
    $noimg = 'checked';
}

#Headline
echo '
        <tr><td class="text_medium" style="padding:5px;">'.mi18n("&Uuml;berschrift").': </td></tr>
        <tr><td style="padding:5px;"><input type="text" name="CMS_VAR[4]" value="CMS_VALUE[4]"></td></tr>
        <tr>
          <td colspan="2" class="text_medium" style="padding:5px;"><b><u>'.mi18n("Bild f&uuml;r Teaser").':</u></b></td>
        </tr>
        <tr>
          <td colspan="2" class="text_medium" style="padding:5px;">'.mi18n("Es wird das erste Bild des Artikels angezeigt.").'</td>
        </tr>';
#Image width
echo '
        <tr><td class="text_medium" style="padding:5px;">'.mi18n("Bildbreite").': </td></tr>
        <tr><td style="padding:5px;"><input type="text" name="CMS_VAR[14]" value="'.$cms_imgsize.'" maxlength="3"></td></tr>';
#Disable images
echo '
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Kein Bild anzeigen").':</td>
          <td style="padding:5px;"><input type="checkbox" name="CMS_VAR[13]" value="true" '.$noimg.'></td>
        </tr>';
#Number of articles
echo '
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Anzahl Artikel begrenzen").':</td>
          <td style="padding:5px;"><input type="text" name="CMS_VAR[15]" value="'.$cms_limit_articles.'"></td>
        </tr>';
#Include start article
echo '
        <tr>
          <td class="text_medium" style="padding:5px;">'.mi18n("Startartikel in Liste einbeziehen").':</td>
          <td style="padding:5px;"><input type="checkbox" name="CMS_VAR[17]" value="yes"'.$cms_include_start_article.'></td>
        </tr>';

echo '</table>';
?><?php
output:

Code: Alles auswählen

<?php
/**
* $RCSfile$
*
* Description: Newslist / ArticleList. Module "Output".
*
* @version 1.0.0
* @author Andreas Lindner
* @copyright four for business AG <www.4fb.de>
*
* {@internal
* created 2005-08-12
* }}
*
* $Id$
*/

cInclude('classes', 'class.article.php');
cInclude('includes', 'functions.api.string.php');
cInclude('includes', 'functions.api.images.php');

if (!isset($tpl) || !is_object($tpl)) {
    $tpl = new Template();
}

$tpl->reset();

$sql = "SELECT
            htmlpath, frontendpath
        FROM
            ".$cfg["tab"]["clients"]." 
        WHERE
            idclient = ".$client." ";

$db->query($sql);

if ($db->next_record()) {
    $htmlpath = $db->f('htmlpath');
    $frontendpath = $db->f('frontendpath');
}

// selected category
$selcat = "CMS_VALUE[1]";
$template = "teaser-standard.html";
// anzahl der zeichen text
$mxtext = 20;

$limit = "CMS_VALUE[15]";

$cms_sort_direction = "CMS_VALUE[16]";
if ($cms_sort_direction == '') {
    $cms_sort_direction = 'desc';
}

if ("CMS_VALUE[3]" == "sortdate") {
    $order = 'lastmodified';
} else {
    $order = 'artsort';
}

if ("CMS_VALUE[17]" != '') {
    $with_start = true;
} else {
    $with_start = false;
}

$newsheadline = "CMS_VALUE[4]";

$tpl->set('s', 'TITLE', $newsheadline);

if (strlen($selcat) > 0 && $selcat != '0') {
    $options = array ('idcat' => $selcat, "start" => $with_start, "order" => $order, "direction" => $cms_sort_direction);

    $list = new ArticleCollection($options);

    $count = $list->count;

    if ($count > 0) {
        if (is_numeric($limit) AND strlen($limit) > 0) {
            if ($limit < $list->count) {
                $limit_art = $limit;
            } else {
                $limit_art = $list->count;
            }
        } else {
            $limit_art = $list->count;
        }

        for ($i = 0; $i < $limit_art; $i ++) {

            $article = $list->nextArticle();

            $article_id = $article->getField('idart');

            $teaser_img = '';
            if ($noimg != 'true') {
                $text_html = $article->getContent('CMS_HTML', 1);

                $regEx = "/<img[^>]*?>.*?/i";
                $match = array ();
                preg_match($regEx, $text_html, $match);

                $regEx = "/(src)(=)(['\"]?)([^\"']*)(['\"]?)/i";
                $img = array ();
                preg_match($regEx, $match[0], $img);
                $img_src = preg_split("/\//", $img[0]);

                $img_name = $img_src[count($img_src) - 1];
                $img_name = preg_replace("/\"/", "", $img_name);
                $img_split = preg_split("/\./", $img_name);
                $img_type = $img_split[count($img_split) - 1];

                $img_split2 = preg_split("/_/", $img_split[0]);

                $name = $img_name;

                if (count($img_split2) > 1) {
                    $img_x = $img_split2[count($img_split2) - 1];
                    $img_y = $img_split2[count($img_split2) - 2];

                    if (is_numeric($img_x) AND is_numeric($img_y)) {
                        $suffix = "_".$img_x."_".$img_y.".".$img_type;
                        $name = preg_replace("/$suffix/", "", $img_name);
                        $name = $name.".[a-zA-Z]{3}";
                    }
                }

                $img_teaser = '';

                if (strlen($name) > 0) {
                    $sql = "SELECT
                                                    *
                                                FROM
                                                    ".$cfg["tab"]["upl"]." 
                                                WHERE
                                                    filename REGEXP '$name' ";

                    //echo "<pre>"; print_r($sql); echo "</pre>";

                    $db->query($sql);

                    if ($db->next_record()) {
                        $filename = $db->f('filename');
                        $dirname = $db->f('dirname');
                    }

                    $img_path = $cfgClient[$client]["upl"]["path"].$dirname.$filename;

                    $img_size = "CMS_VALUE[14]";

                    $img_teaser = capiImgScale($img_path, $img_size, $img_size, $crop = false, $expand = false, $cacheTime = 1000, $wantHQ = false);
                } // end if strlen

                if (strlen($img_teaser) > 0) {
                    $teaser_img = '<img src="'.$img_teaser.'" class="teaser_img">';
                } else {
                    $teaser_img = '';
                }

            } // end if noimg       

            $headline = strip_tags($article->getContent('CMS_HTMLHEAD', 1));
            $headline = str_replace($replace, " ", $headline);

            /*          $subheadline = strip_tags($article->getContent('CMS_HTMLHEAD', 2));
                        $subheadline = str_replace($replace, " ", $subheadline);*/

            $teaserheadline = /*$subheadline."&nbsp;-&nbsp;".*/
            $headline;
            $href = $sess->url("front_content.php?idcat=$selcat&idart=$article_id");
            $teasertext = $article->getField('summary');

            if (strlen(trim($teasertext)) == 0) {
                $teasertext = strip_tags($article->getContent('CMS_HTML', 2));
                $teasertext2 = $teasertext;
                $teasertext = capiStrTrimAfterWord($teasertext, $mxtext);
                if ($teasertext!=$teasertext2) {
                    $teasertext.= '...';
                }
                
            } // end if             

            $teasertext = $teasertext."&nbsp;";

            $tpl->set('d', 'HEADLINE', $teaserheadline);
            $tpl->set('d', 'TEXT', $teasertext);
            $tpl->set('d', 'HREF', $href);
            $tpl->set('d', 'IMG', $teaser_img);
            $tpl->set('d', 'MORE', mi18n("mehr"));

            $tpl->next();

        } // end for

        $tpl->generate('templates/'.$template);

    }
}
?>
Hoffe jemand hat eine Lösung.

Danke!
onda
Zuletzt geändert von onda88 am Do 19. Feb 2009, 09:30, insgesamt 1-mal geändert.
xmurrix
Beiträge: 3215
Registriert: Do 21. Okt 2004, 11:08
Wohnort: Augsburg
Hat sich bedankt: 4 Mal
Danksagung erhalten: 17 Mal
Kontaktdaten:

Re: Problem mit News-Modul

Beitrag von xmurrix »

Hallo onda88,

das Newsmodul verwendet den in Artikeleigenschaften unter Punkt "Zusammenfassung" angegebenen Text für die Anzeige des Textes unterhalb der Headline. Steht in "Zusammenfassung" nicht drin, wird der Inhalt des CMS-Typen "CMS_HTML" mit der Id 2 gesetzt. Bei dir scheint im Artikel das CMS_HTML[2] der Header zu sein, daher wird es doppelt ausgegeben.

Oder in der Zusammenfassung steht das gleich drin, wie in der Headline, das könnte auch die Ursache sein.

Wie ich sehe, gibt es bei dir einen Teasertext, du könntest das im rechten Teaser anzeigen. Wenn du z. B. für den Teasertext CMS_HTML[123] verwendest, brauchst du in der Modulausgabe die Zeile 174

Code: Alles auswählen

$teasertext = strip_tags($article->getContent('CMS_HTML', 2));
gegen

Code: Alles auswählen

$teasertext = strip_tags($article->getContent('CMS_HTML', 123));
ersetzen.

So sollte es auch klappen.

Gruß
xmurrix
CONTENIDO Downloads: CONTENIDO 4.10.1
CONTENIDO Links: Dokumentationsportal, FAQ, API-Dokumentation
CONTENIDO @ Github: CONTENIDO 4.10 - Mit einem Entwicklungszweig (develop-branch), das viele Verbesserungen/Optimierungen erhalten hat und auf Stabilität und Kompatibilität mit PHP 8.0 bis 8.2 getrimmt wurde.
onda88
Beiträge: 77
Registriert: Di 28. Okt 2008, 16:41
Kontaktdaten:

Re: Problem mit News-Modul

Beitrag von onda88 »

Hallo!

Habe das Problem gelöst. Der Fehler befand sich nicht im Modul sondern im Modul-Temlate, wo "{TEXT}" zwei mal ausgegeben wurde.
Trotzdem Danke!

Grüße,
onda
Gesperrt