1

(6 replies, posted in Snippets)

it works I guess wink

2

(6 replies, posted in Snippets)

try change:

$content = strtolower(Pages::content($page['slug']));

to :

$content = strtolower(Page::content($page['slug']));


Pages to Page

3

(6 replies, posted in Snippets)

barichello wrote:

Are you sure this is working?

It does not seem to work on my blog (http://barichello.coffee/blog).

Try "attention", for example. It is in the content on the body of the first post but the script returns 0 matches.


are you sure you have copied above code ?
it works for me

4

(6 replies, posted in Snippets)

you are right it does not return searching phrase

this line: $content = strtolower(Pages::content($page['slug'])); should return page content

i will think about it

5

(6 replies, posted in Plugins)

search blogs's post by content

http://forum.monstra.org/post/4414/#p4414

6

(6 replies, posted in Snippets)

use this snippet if you want search blog's post by content or title


<form method="post" class="form-horizontal col-md-12" action="">
<div class="form-group">
  <div class="input-group">
    <input type="text" name="name" class="form-control" placeholder="search by title ...">
    <span class="input-group-btn">
      <button class="btn btn-default btn-link" type="submit" name="submit"><i class="fa fa-search"></i></button>
    </span>
  </div>
</div>
</form>


<?php $pages = Page::children('blog'); ?>

<?php 

$name = strtolower($_POST['name']);

if(isset($_POST['submit'])) 
{
    
    $counter = 0;
    
       echo '<p>results for <b>' .$_POST['name']. '</b> :</p>';
       echo '<ul class="list-unstyled">';
    
    foreach($pages as $page) 
                
    {   $content = strtolower(Pages::content($page['slug']));
          $title = strtolower($page['title']);   
        
        if (strpos($title , $name) !== false OR strpos($content , $name) !== false)  {
            
            echo '<li>';
            echo '<a href="blog/'.$page['slug'].'">' .$page['title']. '</a>';
            echo '</li>';    
            
            $counter++;
        }    
        
     }
    echo '</ul>';
    
    if ($counter === 0) {
        
        echo '<p><i>no matches found</i></p>';
    }
    
    else {
        
        echo '<p>found ' .$counter. '</p>';
        
    }
}

?>

7

(0 replies, posted in Snippets)

simple snippet, which shows how to use conditions with Monstra variables


<?php 

if (Site::title() == 'Your Title') 

{ echo Site::name() .' Your Text ' ; }

     else 

{ echo Site::name() .' - '. Site::title() ; }

 ?>

8

(6 replies, posted in Plugins)

Thanks for respecting of copyrights

9

(15 replies, posted in Plugins)

need help for how to set up template for news site

i have following url:

news/something

i made a template for news item but i can't do template for news index

when i click to news i go to te main site(home)

10

(5 replies, posted in Themes)

looks good

legal template

12

(0 replies, posted in Snippets)

simple snippet for searching blog's posts via title

<form method="post" class="form-horizontal col-md-12" actiom="">
<div class="form-group">
  <div class="input-group">
    <input type="text" name="name" class="form-control" placeholder="search by title ...">
    <span class="input-group-btn">
      <button class="btn btn-default btn-link" type="submit" name="submit"><i class="fa fa-search"></i></button>
    </span>
  </div>
</div>
</form>


<?php $pages = Page::children('blog'); ?>

<?php 

$name = strtolower($_POST['name']);

if(isset($_POST['submit'])) 
{
    
    $counter = 0;
    
       echo '<p>results for <b>' .$_POST['name']. '</b> :</p>';
       echo '<ul class="list-unstyled">';
    
    foreach($pages as $page) 
                
    {   $title = strtolower($page['title']);    
        
        if (strpos($title , $name) !== false)  {
            
            echo '<li>';
            echo '<a href="blog/'.$page['slug'].'">' .$page['title']. '</a>';
            echo '</li>';    
            
            $counter++;
        }    
        
     }
    echo '</ul>';
    
    if ($counter === 0) {
        
        echo '<p><i>no matches found</i></p>';
    }
    
    else {
        
        echo '<p>found ' .$counter. '</p>';
        
    }
}

?>

13

(4 replies, posted in Questions)

if blog post's title contains string "name" it shows list with proper titles with links

<?php $pages = Page::children('blog'); ?>

<ul class="list-unstyle">
<?php 
    foreach($pages as $page) 
    {
        if (strpos($page['title'] ,'name') !== false) {
            echo '<li>';
            echo '<a href="blog/'.$page['slug'].'">' .$page['title']. '</a>';
            echo '</li>';
        }
    }    

?>
</ul>

14

(4 replies, posted in Questions)

<?php $pages = Page::children('blog'); ?>

<ul class="list-unstyle">
<?php 
    foreach($pages as $page) 
    {
        if (strpos($page['title'] ,'name') !== false) {
            echo '<li>';
            echo $page['title'];
            echo '</li>';
        }
    }    

?>
</ul>

above code sorts blog post titles via name value

15

(4 replies, posted in Questions)

thx a lot it is working
i am trying to do small snippet for blog's post to find posts via title

16

(4 replies, posted in Questions)

It does not work help please

<?php $pages = Page::children('blog'); ?>




<ul class="list-unstyle">
<?php foreach($pages as $page) { ?>
    
if (strpos(<?php echo $page['title']; ?> ,'a';) !== false) {
    <li>tak</li>;
    }     

<?php } ?>

</ul>

17

(0 replies, posted in Snippets)

It comes from: http://php.snipplicious.com/snippet/30/time-ago

Time ago

Compute how many days/weeks/years ago is given timestamp ago from current date. As you can see on facebook for example like "2 days ago"

function timeAgo($time_ago)
{
    $cur_time   = time();
    $time_elapsed   = $cur_time - $time_ago;
    $seconds    = $time_elapsed ;
    $minutes    = round($time_elapsed / 60 );
    $hours      = round($time_elapsed / 3600);
    $days       = round($time_elapsed / 86400 );
    $weeks      = round($time_elapsed / 604800);
    $months     = round($time_elapsed / 2600640 );
    $years      = round($time_elapsed / 31207680 );
    // Seconds
    if($seconds <= 60){
        return "just now";
    }
    //Minutes
    else if($minutes <=60){
        if($minutes==1){
            return "one minute ago";
        }
        else{
            return "$minutes minutes ago";
        }
    }
    //Hours
    else if($hours <=24){
        if($hours==1){
            return "an hour ago";
        }else{
            return "$hours hrs ago";
        }
    }
    //Days
    else if($days <= 7){
        if($days==1){
            return "yesterday";
        }else{
            return "$days days ago";
        }
    }
    //Weeks
    else if($weeks <= 4.3){
        if($weeks==1){
            return "a week ago";
        }else{
            return "$weeks weeks ago";
        }
    }
    //Months
    else if($months <=12){
        if($months==1){
            return "a month ago";
        }else{
            return "$months months ago";
        }
    }
    //Years
    else{
        if($years==1){
            return "one year ago";
        }else{
            return "$years years ago";
        }
    }
}

echo "<h2>See examples for random timestamps</h2>";

$timestamp = rand(100000000,1000000000);
echo "<b>".$timestamp."</b>: " . timeAgo($timestamp) . "<br>";


$timestamp = time()-rand(1000000,10000000);
echo "<b>".$timestamp."</b>: " . timeAgo($timestamp) . "<br>";


$timestamp = time()-rand(10000,1000000);
echo "<b>".$timestamp."</b>: " . timeAgo($timestamp) . "<br>";

18

(18 replies, posted in Plugins)

any deadline for release this plugin?

19

(13 replies, posted in Development)

search plugin for blog?

20

(1 replies, posted in Development)

how to change this:

private static function hits($id, $hits) {
        if (Session::exists('hits'.$id) == false) {
            $hits++;
            if(News::$news->updateWhere('[id='.$id.']', array('hits' => $hits))) {
                Session::set('hits'.$id, 1);
            }
        }

        return $hits;
    }

to make blog post view hit counter?
the above code is from kanekt news plugin

21

(1 replies, posted in Snippets)

add to your blog.plugin.php:

/**
     * Get Blog Total Posts number
     *
     *  <code> 
     *      echo Blog::getTotalPosts();
     *  </code>
     *
     * @return string
     */
    public static function getTotalPosts() {

$posts = Pages::$pages->select('[parent="'.Blog::$parent_page_name.'" and status="published"]');

$count = count($posts); 

return  $count;

    }

add to your template:

<?php echo Blog::getTotalPosts(); ?>

it returns total number of published posts in blog

law

23

(18 replies, posted in Plugins)

ok i am waiting patiently

24

(18 replies, posted in Plugins)

ok i see it 2% progress and still growing ...

25

(18 replies, posted in Plugins)

ok the new site looks fine but i can't find chat live plugin, to be honest i am waiting for it curiosly ...