Page 1 of 2

How to : Latest post filter tags?

Posted: Sat Mar 26, 2016 10:07 am
by mahmut
LATEST_POSTS recent issues with plug-in may filter according to the specified label ? How can I do it?

Thanks.

Re: How to : Latest post filter tags?

Posted: Sat Mar 26, 2016 6:17 pm
by Edi
mahmut wrote:LATEST_POSTS recent issues with plug-in may filter according to the specified label ? How can I do it?
The plugin shows the latest or newest posts. "Plugin label" means the title of the section with the list of the latest posts shown in the frontend.

Re: How to : Latest post filter tags?

Posted: Sat Mar 26, 2016 6:40 pm
by mahmut
Edi wrote:
mahmut wrote:LATEST_POSTS recent issues with plug-in may filter according to the specified label ? How can I do it?
The plugin shows the latest or newest posts. "Plugin label" means the title of the section with the list of the latest posts shown in the frontend.
Thank you. So I want to add that extension profile picture . But I get the following error . What could be the reason? Thank you.

Edit // + I would also like to add the image thumbnail .

Error messagge:

Code: Select all

Fatal error: Call to a member function profilePicture() on null in C:\xampp\htdocs\bl-plugins\latest_posts\plugin.php on line 54
Line 54:

Code: Select all

$html .= '<a href="'.$Post->permalink().'" class="author"><img src="'.$User->profilePicture().'" alt="" /></a>';

Re: How to : Latest post filter tags?

Posted: Sun Mar 27, 2016 3:39 pm
by Edi
mahmut wrote: So I want to add that extension profile picture . But I get the following error . What could be the reason? Thank you.

Edit // + I would also like to add the image thumbnail .
Where do you like to add it?

Re: How to : Latest post filter tags?

Posted: Sun Mar 27, 2016 4:11 pm
by mahmut
Edi wrote:
mahmut wrote: So I want to add that extension profile picture . But I get the following error . What could be the reason? Thank you.

Edit // + I would also like to add the image thumbnail .
Where do you like to add it?
Thanks.

Latest post plugin.

Example:
Image

My code:

Code: Select all

		foreach($posts as $Post)
		{

		$html .= '<article class="mini-post">'.PHP_EOL;
		$html .= '	<header>'.PHP_EOL;
		$html .= '		<h3><a href="'.$Post->permalink().'" title="'.$Post->title().'">'.$Post->title().'</a></h3>'.PHP_EOL;
		$html .= '		<time class="published" datetime="">'.$Post->date().'</time>'.PHP_EOL;
		$html .= '		<a href="'.$Post->permalink().'" class="author"><img src="" title="" alt="" /></a>'.PHP_EOL;
		$html .= '	</header>'.PHP_EOL;
		$html .= '		<a href="'.$Post->permalink().'" class="image"><img src="'.$Post->coverImage().'" alt="'.$Post->title().'" title="'.$Post->title().'" /></a>'.PHP_EOL;
		$html .= '</article>'.PHP_EOL;
		}
1. I want to add thumbnail instead cover .
2. Add author profile photo
3. To writing the date of Turkish

Thanks.

Latest post plugin full code:

Code: Select all

<?php

class pluginLatestPosts extends Plugin {

	public function init()
	{
		$this->dbFields = array(
			'label'=>'Başlıca konular',
			'amount'=>5
		);
	}

	public function form()
	{
		global $Language;

		$html  = '<div>';
		$html .= '<label>'.$Language->get('Plugin label').'</label>';
		$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
		$html .= '</div>';

		$html .= '<div>';
		$html .= '<label>'.$Language->get('Amount of posts').'</label>';
		$html .= '<input name="amount" id="jsamount" type="text" value="'.$this->getDbField('amount').'">';
		$html .= '</div>';

		return $html;
	}

	public function SideIki()
	{
		$posts = buildPostsForPage(0, $this->getDbField('amount'), true, false);

		$html  = '<div class="plugin plugin-baslica-konular">'.PHP_EOL;

		$label = $this->getDbField('label');
		if( !empty($label) ) {
			$html .= '	<h2 class="plugin-baslik">'.$label.'</h2>'.PHP_EOL;
		}

		$html .= '<div class="plugin-content">'.PHP_EOL;
		$html .= '	<section>'.PHP_EOL;
		$html .= '		<div class="mini-posts">'.PHP_EOL;

		foreach($posts as $Post)
		{

		$html .= '<article class="mini-post">'.PHP_EOL;
		$html .= '	<header>'.PHP_EOL;
		$html .= '		<h3><a href="'.$Post->permalink().'" title="'.$Post->title().'">'.$Post->title().'</a></h3>'.PHP_EOL;
		$html .= '		<time class="published" datetime="">'.$Post->date().'</time>'.PHP_EOL;
		$html .= '		<a href="'.$Post->permalink().'" class="author"><img src="author photo????" title="" alt="" /></a>'.PHP_EOL;
		$html .= '	</header>'.PHP_EOL;
		$html .= '		<a href="'.$Post->permalink().'" class="image"><img src="thubmanil image??" alt="'.$Post->title().'" title="'.$Post->title().'" /></a>'.PHP_EOL;
		$html .= '</article>'.PHP_EOL;

		}
		
		$html .= '</div>'.PHP_EOL;
		$html .= '</section>'.PHP_EOL;
 		$html .= '</div>'.PHP_EOL;
 		$html .= '</div>'.PHP_EOL;

		return $html;
	}
}

Re: How to : Latest post filter tags?

Posted: Mon Mar 28, 2016 1:02 am
by Edi
Step by step... There are some modifications necessary.

First the cover image. Basically the following works for cover images as part of the latest posts (it's a slight modification of the plugin).

Code: Select all

		foreach($posts as $Post)
		{

			$html .= '<li>';

			if($Post->coverImage()) {
			$html .= '<a href="'.$Post->permalink().'"><img src="'.$Post->coverImage().'" alt="Cover Image"></a>';
			}

			$html .= '<a href="'.$Post->permalink().'">'.$Post->title().'</a>';
			$html .= '</li>';
		}
At the moment it's better to use the image instead of the thumbnail. Beside the thumbnail is always shown as square it's size is greater than the one of the image (this has to be fixed).

It makes no sense to use the semantical tag <article> in a sidebar. It should be used only for the main content of a post or page or for comments:

http://www.w3schools.com/tags/tag_article.asp

https://developer.mozilla.org/en-US/doc ... nt/article

Re: How to : Latest post filter tags?

Posted: Mon Mar 28, 2016 7:58 am
by mahmut
Thanks, okay.

I wanted to add thumbnail for page opening speed.
So how do I make the user profile picture, and date settings ?

Edi wrote:Step by step... There are some modifications necessary.

First the cover image. Basically the following works for cover images as part of the latest posts (it's a slight modification of the plugin).

Code: Select all

		foreach($posts as $Post)
		{

			$html .= '<li>';

			if($Post->coverImage()) {
			$html .= '<a href="'.$Post->permalink().'"><img src="'.$Post->coverImage().'" alt="Cover Image"></a>';
			}

			$html .= '<a href="'.$Post->permalink().'">'.$Post->title().'</a>';
			$html .= '</li>';
		}
At the moment it's better to use the image instead of the thumbnail. Beside the thumbnail is always shown as square it's size is greater than the one of the image (this has to be fixed).

It makes no sense to use the semantical tag <article> in a sidebar. It should be used only for the main content of a post or page or for comments:

http://www.w3schools.com/tags/tag_article.asp

https://developer.mozilla.org/en-US/doc ... nt/article

Re: How to : Latest post filter tags?

Posted: Mon Mar 28, 2016 3:00 pm
by Edi
Next step. the image of the author.

Code: Select all

		foreach($posts as $Post)
		{

			$User = $Post->user();

			$html .= '<li>';

			if($Post->coverImage()) {
				$html .= '<a href="'.$Post->permalink().'"><img src="'.$Post->coverImage().'" alt="Cover Image"></a>';
			}

			$html .= '<a href="'.$Post->permalink().'">'.$Post->title().'</a>';

			if($User->profilePicture()) {
				$html .= '<div class="author"><img src="'.$User->profilePicture().'" alt=""></div>';
			}

			$html .= '</li>';

		}

Re: How to : Latest post filter tags?

Posted: Mon Mar 28, 2016 3:20 pm
by Edi
Next step the date as explained earlier at Post date time language change?.

Code: Select all

		foreach($posts as $Post)
		{

			$User = $Post->user();

            // Local month
            $nmeng = array('January','February','March','April','May','June','July','August','September','October','November','December');
            $nmger = array('Januar','Februar','M&auml;rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');
            $dt = $Post->date();
            $dt = str_ireplace($nmeng, $nmger, $dt);

			$html .= '<li>';

			if($Post->coverImage()) {
				$html .= '<a href="'.$Post->permalink().'"><img src="'.$Post->coverImage().'" alt="Cover Image"></a>';
			}

			$html .= '<a href="'.$Post->permalink().'">'.$Post->title().'</a>';
		    $html .= '<time class="published" datetime="2015-11-01">'.$dt.'</time>';

			if($User->profilePicture()) {
				$html .= '<div class="author"><img src="'.$User->profilePicture().'" alt=""></div>';
			}

			$html .= '</li>';

		}
Missing is only the styling with CSS.

Re: How to : Latest post filter tags?

Posted: Mon Mar 28, 2016 4:26 pm
by mahmut
Thank you very, very much . I love you Edi! :)

Thumbnail additions are not we ? If not, no problem , thank you.

Edi wrote:Next step the date as explained earlier at Post date time language change?.

Code: Select all

		foreach($posts as $Post)
		{

			$User = $Post->user();

            // Local month
            $nmeng = array('January','February','March','April','May','June','July','August','September','October','November','December');
            $nmger = array('Januar','Februar','M&auml;rz','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');
            $dt = $Post->date();
            $dt = str_ireplace($nmeng, $nmger, $dt);

			$html .= '<li>';

			if($Post->coverImage()) {
				$html .= '<a href="'.$Post->permalink().'"><img src="'.$Post->coverImage().'" alt="Cover Image"></a>';
			}

			$html .= '<a href="'.$Post->permalink().'">'.$Post->title().'</a>';
		    $html .= '<time class="published" datetime="2015-11-01">'.$dt.'</time>';

			if($User->profilePicture()) {
				$html .= '<div class="author"><img src="'.$User->profilePicture().'" alt=""></div>';
			}

			$html .= '</li>';

		}
Missing is only the styling with CSS.