Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2009-12-23 22:08:56

phuture303
Member
Registered: 2008-09-14
Posts: 127

[de-de] wet_recent_comments, nicht artikel-sensitiv

Hallo, ich würde gerne das Plugin wet_recent_comments einsetzen.

When wet_recent_comments is used in a page template, comments are taken from all articles, while in an article form comments are specifically chosen from the ones concerning the current article.

Genau DAS möchte ich aber nicht, sondern sowohl auf /blog als auch auf /blog/einzelseite die Kommentare artikelübergreifend anreißen.

Nun verstehe ich von PHP nicht die Bohne, habe mir das Plugin zumindest schon so hingebogen, dass ich die Kommentare in einer ungeordneten Liste so

anzeigen kann. Der Code dafür steht in der Seitenvorlage. Das o.g. (der Artikelkontext) ist allerdings zu hoch für mich. Kann mir jemand weiterhelfen?

Vielen Dank & weihnachtliche Grüße
David

PS:

function wet_recent_comments($atts)
{
	global $pretext, $thisarticle, $comments_dateformat;


	extract(lAtts(array(
		'label' => '',
		'limit' => '10',
		'break' => 'li',
		'wraptag' => 'ul',
		'showcomment' => 'no',
		'striptags' => 'no',
		'maxwords'  => 50,
		'labeltag'  => '',
		'dateformat' => '',
		'class' => __FUNCTION__
	),$atts));

	$clause = " where ".PFX."txp_discuss.visible='1'";

    if (!empty($thisarticle['thisid'])) {
	  $clause .= " and ".PFX."textpattern.ID = '".$thisarticle['thisid']."'";
	}

	$q = "select ".PFX."txp_discuss.*,".PFX."txp_discuss.posted as comment_posted,".PFX."textpattern.* from ".PFX."txp_discuss left join ".PFX."textpattern on ".PFX."textpattern.ID = ".PFX."txp_discuss.parentid".$clause." order by ".PFX."txp_discuss.posted desc limit $limit";

	$rs = getRows($q);

	if ($rs) {
		foreach ($rs as $a) {

			extract($a);

            if ($showcomment == 'no') {
                $message = '';
            } else {
                if ($striptags != 'no') $message = strip_tags($message);
                $wrds = explode(' ', $message);

                if(count($wrds) > $maxwords){
                    $message = '';

                    for($i=0; $i<$maxwords; $i++) {
                        $message .= $wrds[$i].' ';
                    }
                    $message = $message.'…';
                } else {
                    $message = $message;
                }
            }

			if( !empty($dateformat) ) {
				$dateformat = str_replace( 'default', $comments_dateformat, $dateformat );
				$comments_date = ' <span>'.safe_strftime( $dateformat, strtotime($comment_posted) ).'</span>';
			} else {
				$comments_date = '';
			}

			$out[] = $name.': <a href="'.permlinkurl_id($ID).'#c'.$discussid.'">'.$message.'</a>';
		}

        if (is_array($out)) {
            return doLabel($label, $labeltag).doWrap($out, $wraptag, $break, $class);
        }
	}
	return '';
}

Offline

#2 2009-12-24 11:57:50

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: [de-de] wet_recent_comments, nicht artikel-sensitiv

Nimm doch den TXP-internen Tag <txp:recent_comments />.!


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#3 2009-12-24 13:30:54

phuture303
Member
Registered: 2008-09-14
Posts: 127

Re: [de-de] wet_recent_comments, nicht artikel-sensitiv

Kann ich den internen Tag denn genau so umschreiben wie das Plugin von Robert? Von Haus aus liefert mir das Tag nicht den gewünschten Output :-)

Offline

#4 2009-12-25 12:18:36

trenc
Plugin Author
From: ⛵️, currently Göteborg, SE
Registered: 2008-02-27
Posts: 574
Website GitHub

Re: [de-de] wet_recent_comments, nicht artikel-sensitiv

Hi,

Kann ich den internen Tag denn genau so umschreiben wie das Plugin von Robert? Von Haus aus liefert mir das Tag nicht den gewünschten Output :-)

würde ich nicht empfehlen. Wenn Du nur die Liste als Output (wie oben beschrieben) benötigst, sollte folgendes ausreichen (nicht getestet):

<txp:recent_comments limit="5" wraptag="ul">
  <li><txp:comment_name link"0" />: <txp:comment_message /></li>
</txp:recent_comments>

So in etwa. Nur für das Kürzen der des Kommentares müsstest Du ein anderes Plugin/Script bemühen, da das nicht unterstützt wird.


Digital nomad, sailing the world on a sailboat: 32fthome.com

Offline

#5 2009-12-25 13:40:39

phuture303
Member
Registered: 2008-09-14
Posts: 127

Re: [de-de] wet_recent_comments, nicht artikel-sensitiv

Ah, danke für den Tipp! Ich vergesse gerne mal, dass man die Tags oftmals nicht nur als Single-Tag verwenden kann…

Offline

Board footer

Powered by FluxBB