1 (edited by gabri3lmarques 2016-05-20 18:20:12)

Topic: Seacrh Pluign

Hello Folks,

I am still knowing about Monstra and PHP, so i have ideas but i don't know how to do it.

Does anybody whith more skills and experience know how to build a search plugin for Monstra? It would be very, very useful!!

I guess that some plugin that works similar to the tags function, but instead of click on a tag you type something in a field and get some results, would be good enough.

Thanks for helping!

Re: Seacrh Pluign

hi

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>';
        
    }
}

?>
Here you will find templates for monstra and morfy xxwebplus
Best cms

Re: Seacrh Pluign

Hello, xxwebplus!

Thank you very much for the answer.

Re: Seacrh Pluign

Thanks for this impressive answer

Re: Seacrh Pluign

Thanks for respecting of copyrights

Re: Seacrh Pluign

Can anyone extend this code to search more than only titles?

Re: Seacrh Pluign

search blogs's post by content

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