Ich habe mir überlegt das Newsmodul aus dem Beispielmandanten zu missbrauchen.
Soweit konnte ich ersteinmal das Teasern des Images aus dem Artikel rausschmeissen.
Da meine PHP Kenntnisse jedoch nicht ausreichen, kann ich es nicht vollständig anpassen und bin auf Eure wohlwollende Hilfe angewiesen.
Ich möchte das Modul nun so abändern, dass es mir in der Ausgabe, also der Generierung des Ankers (Template) den Artikelnamen als Bezeichnung ausgibt. Der Pfad im Anker zu den in der Kategorie befindlichen Artikeln wird ja bereits richtig generiert.
Wie kann oder muss ich die Datenbankabfrage dahingehend abändern, dass ich an den Artikelnamen herankomme und diesen als ?Variable? im Template verwenden kann?
Vielleicht ist jemand von Euch so nett und hilft mir dabei, nachstehend habe ich den Code gepostet:
INPUT
Code: Alles auswählen
?><?php
/***********************************************
* CONTENIDO MODUL - INPUT
*
* Modulname : News
* Author(s) : Andreas Lindner, 4fb
* Copyright : Contenido - four for business, Andreas Lindner
* Created : 12.08.2005
************************************************/
#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ählen: </td></tr>
<tr><td class="text_medium" style="padding:5px">';
echo buildCategorySelect("CMS_VAR[1]", "CMS_VALUE[1]");
echo ' <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("Ü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ü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="text" name="CMS_VAR[17]" value="yes"'.$cms_include_start_article.'></td>
</tr>';
echo '</table>';
?><?php
OUTPUT
Code: Alles auswählen
<?php
/***********************************************
* CONTENIDO MODUL - OUTPUT
*
* Modulname : News
* Author(s) : Andreas Lindner, 4fb
* Copyright : Contenido - four for business, Andreas Lindner
* Created : 12.08.2005
************************************************/
cInclude('classes', 'class.article.php');
cInclude('includes', 'functions.api.string.php');
cInclude('includes', 'functions.api.images.php');
if (!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]";
//echo "sel $selcat<br>";
$template = "navigation-startseite.html";
//echo "tpl $template<br>";
// anzahl der zeichen text
$mxtext = 200;
$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';
}
$newsheadline = "CMS_VALUE[4]";
$tpl->set('s', 'TITLE', $newsheadline);
if (strlen($selcat) > 0 AND $selcat != '0') {
$options = array ('idcat' => $selcat, "start" => false, "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');
$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." - ".*/
$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', 1));
$teasertext2 = $teasertext;
$teasertext = capiStrTrimAfterWord($teasertext, $mxtext);
if ($teasertext!=$teasertext2) {
$teasertext.= '...';
}
} // end if
$teasertext = $teasertext." ";
$tpl->set('d', 'HEADLINE', $teaserheadline);
$tpl->set('d', 'TEXT', $teasertext);
$tpl->set('d', 'HREF', $href);
$tpl->next();
} // end for
$tpl->generate('templates/'.$template);
}
}
?>
TEMPLATE
Code: Alles auswählen
<ul>
<!-- BEGIN:BLOCK -->
<li><a href="{HREF}" alt="{HEADLINE}" title="{HEADLINE}">{HREF}</a></li>
<!-- END:BLOCK -->
</ul>