How to : Latest post filter tags?
Posted: Sat Mar 26, 2016 10:07 am
LATEST_POSTS recent issues with plug-in may filter according to the specified label ? How can I do it?
Thanks.
Thanks.
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.mahmut wrote:LATEST_POSTS recent issues with plug-in may filter according to the specified label ? How can I do it?
Thank you. So I want to add that extension profile picture . But I get the following error . What could be the reason? Thank you.Edi wrote: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.mahmut wrote:LATEST_POSTS recent issues with plug-in may filter according to the specified label ? How can I do it?
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
Code: Select all
$html .= '<a href="'.$Post->permalink().'" class="author"><img src="'.$User->profilePicture().'" alt="" /></a>';
Where do you like to add it?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 .
Thanks.Edi wrote:Where do you like to add it?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 .
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;
}
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;
}
}
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>';
}
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).
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).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>'; }
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
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>';
}
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ä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>';
}
Edi wrote:Next step the date as explained earlier at Post date time language change?.
Missing is only the styling with CSS.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ä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>'; }