×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Avatar + Username in preview show

Avatar + Username in preview show 14 years 4 months ago #7982

  • foton
  • foton's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
Hello,
I like to add avatar and username in preview show. I have add some code {avatar_picture} and {username} in index.html of my template, but no luck. Anyone could help ?
I'm using Joomla 1.5.15 + !JoomlaComment 4.0 beta 2

thanks

Avatar + Username in preview show 14 years 4 months ago #7985

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
you will actually have to edit the comment.class.php to do this. Only changes to the index.html file will not do the job.

Avatar + Username in preview show 14 years 4 months ago #7988

  • foton
  • foton's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
I already add some code in comment.class.php to do that job, but still no luck. I'm not expert with php code. Would you advise me the code that i have to add in comment.class.php

thanks

Avatar + Username in preview show 14 years 4 months ago #8047

  • foton
  • foton's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
i already add this code to comment.class.php
/*
     * makes a profile link to CB
     *
     * @access public
     * @param mixed $s - user name
     * @param int $id - user id
     * @return - html link to profile or just the user name if id is missing
     */
    function profileLink($s, $id)
    {
	if(strcmp($id,'')) {
	    $link = JRoute::_('index.php?option=com_comprofiler&task=userProfile&user='.$id);
	    return "<a href='$link'>".$s."</a>";
	} else {
	    return $s;
	}
    }
/**
 * creates the write more( Number of comments) button
 * and generated the comment preview
 * @return html
 */
    function insertCountButton()
    {
        $address = $this->_comObject->linkToContent( $this->_content_id );
	$number = $this->countComments();
 
        $html = $this->_readon;
 
        /* {READON_xxx} 	*/
        $html	= str_replace('{READON_LINK}', $address , $html);
	$html	= str_replace('{READON_WRITE_COMMENT}', _JOOMLACOMMENT_WRITECOMMENT, $html);
	$html	= str_replace('{READON_COUNT}', $number, $html);
	$html	= str_replace('{READON_COMMENTS}', $this->comments($number), $html);
 
        /* {BLOCK-preview} */
	if ($this->_preview_visible) {
	    $database =& JFactory::getDBO();
	    $database->SetQuery("SELECT * FROM jos_comment WHERE contentid='$this->_content_id' AND component='$com' AND published='1' ORDER BY date DESC");
	    $data = $database->loadAssocList();
	}
        $display	= $this->_preview_visible && ($data!=null);
        $html 		= JOSC_utils::checkBlock('BLOCK-preview', $display, $html);
        if ($display) {
	    $index = 0;
	    $previewlines = '';
	    foreach($data as $item) {
		if ($index >= $this->_preview_lines)
		    break;
		if ($item['title'] != '') {
		    $title = stripslashes($item['title']);
		} else {
		    $title = stripslashes($item['comment']);
		}
		if (JString::strlen($title) > $this->_preview_length)
		    $title = JString::substr($title, 0, $this->_preview_length) . '...';
 
		$previewline 	= $this->_previewline;
				/* {username} */
		$previewline	= str_replace('{username}', $this->profileLink($name, $this->_user_id), $previewline);
				/* {avatar_picture} */
		$previewline	= str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $previewline);
	            /* {PREVIEW_LINK} */
		$previewline	= str_replace('{PREVIEW_LINK}', $address, $previewline);
	            /* {PREVIEW_DATE} */
		$previewline	= str_replace('{PREVIEW_DATE}', JOSC_utils::getLocalDate($item['date'],$this->_date_format) , $previewline);//date($this->_date_format,strtotime($item['date'])) , $previewline);
	            /* {PREVIEW_TITLE} */
		$previewline	= str_replace('{PREVIEW_TITLE}', $title, $previewline);
	            /* {PREVIEW_TITLE} */
		$previewline	= str_replace('{id}', $item['id'], $previewline);
 
		$index++;
		$previewlines	.= $previewline;
	    }
			/* {preview-lines} */
	    $html = str_replace('{preview-lines}', $previewlines, $html);
 
	}
        return $html;
    }
 

and this code to index.html
{previewline}
	<div class='comment_preview'>
    <div>{username}</div>
    	{avatar_picture} <a href="{PREVIEW_LINK}#josc{id}">{PREVIEW_DATE}<b>{PREVIEW_TITLE}</b></a>
	</div>
{/previewline}

but not working

anyone can help?

Avatar + Username in preview show 14 years 4 months ago #8048

  • foton
  • foton's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
double post

Avatar + Username in preview show 14 years 4 months ago #8049

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Look at the post_htmlCode() function. Perhaps you can directly copy the code from there and see if it works.

Avatar + Username in preview show 14 years 4 months ago #8059

  • foton
  • foton's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 5
  • Thank you received: 0
unfortunately it's not work
  • Page:
  • 1
Time to create page: 0.107 seconds