News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

sp vmsearch module

Started by guardiano78, June 07, 2016, 10:56:43 AM

Previous topic - Next topic

guardiano78

Hello,
i have a problem with pagination search.
In the joomla configuration i set to yes "Search Engine Friendly URLs" and "Adds Suffix to URL"
this is my default page:

<?php

    
/**
    * VirtueMart Categories Module
    */

?>

<div class="serchline">
<div class="<?php echo $moduleclass_sfx?> sp-vmsearch" id="sp-vmsearch-<?php echo $module_id ?>">
    <form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&search=true&limitstart=0' ); ?>" method="post">
       <div class="search-input-wrapper">
            <input type="text" name="keyword" autocomplete="off" class="sp-vmsearch-box" required="required" value="<?php echo JRequest:: getVar('keyword'?>" />
        </div>
        <div class="sp-vmsearch-categorybox">
            <select name="virtuemart_category_id" class="sp-vmsearch-categories">
                <option value="0" data-name="<?php echo JText::_('SP_VMSEARCH_ALL_CATEGORIES'?>"><?php echo JText::_('SP_VMSEARCH_ALL_CATEGORIES'?></option>
                <?php
                    
echo $modSPVMSearchHelper->getTree();
                
?>

            </select>
        </div>
         <div class="search-button-wrapper">
            <button type="submit" class="search-button button"><?php echo JText::_('SP_VMSEARCH_SEARCH_BUTTON'?></button>
        </div> 
        <div class="clearfix"></div>
        <input type="hidden" name="limitstart" value="0" />
        <input type="hidden" name="option" value="com_virtuemart" />
        <input type="hidden" name="view" value="category" />
    </form>
</div>
      <div class="ac_result" style="display:none;"></div>
      <div class="sropen"><i class="fa fa-search"></i></div>
      <div class="srclose"><i class="fa fa-times"></i></div>

</div>

<script type="text/javascript">
    jQuery(function($){
           
            // change event
            $('#sp-vmsearch-<?php echo $module_id ?> .sp-vmsearch-categories').on('change', function(event){
                    var $name = $(this).find(':selected').attr('data-name');
                    $('#sp-vmsearch-<?php echo $module_id ?> .sp-vmsearch-category-name .category-name').text($name);

            });


            // typeahed
            $('#sp-vmsearch-<?php echo $module_id ?> .sp-vmsearch-box').typeahead({
                    items  : '<?php echo $max_search_suggest?>',
                    source : (function(query, process){
                            return $.post('<?php echo JURI::current() ?>',
                                {
                                    'module_id': '<?php echo $module_id?>',
                                    'char': query,
                                    'category': $('#sp-vmsearch-<?php echo $module_id ?> .sp-vmsearch-categories').val()
                                },
                                function (data) {
                                    return process(data);
                                },'json');
                    }),
            });
    });
    </script>

and this is the source code of mod_sp_vmsearch.php :

<?php

    
/**
    * SP VirtueMart Category search module
    */

    // no direct access
    
defined('_JEXEC') or die('Restricted access');

    require(
'helper.php');
    if (!
class_exists'VmConfig' )) require(JPATH_ADMINISTRATOR DS 'components' DS 'com_virtuemart'.DS.'helpers'.DS.'config.php');

    
VmConfig::loadConfig();

    
/* Settings */
    
$category_model VmModel::getModel('Category');
    
$category_id $params->get('category_id'0);
    
$moduleclass_sfx $params->get('moduleclass_sfx','');
    
$max_search_suggest $params->get('max_search_suggest','10');
    
$load_jquery $params->get('loadjquery','1');  // Load JQuery
    
$load_typahead $params->get('loadtypeahead','1');  // Load JQuery
    
    
$module_id $module->id;
    
$active_category_id JRequest::getInt('virtuemart_category_id''0');
    
$vendor_id '1';
    
$moduleName   basename(dirname(__FILE__));
    
$categories $category_model->getChildCategoryList($vendor_id$category_id);

    if(empty(
$categories)) return false;

    
$modSPVMSearchHelper = new modSPVMSearchHelper();
    
$modSPVMSearchHelper->categoryModel $category_model;
    
$modSPVMSearchHelper->generateTree($categories$active_category_id0);


    
$doc      JFactory::getDocument();
    
$cssFile  JPATH_THEMES'/'.$doc->template.'/css/'.$moduleName.'.css';


    if( 
$load_jquery=='1' ){
        
$doc->addScript(JURI::base(true) . '/modules/'.$moduleName.'/assets/js/jquery-1.9.1.min.js');
    }
    
    if( 
$load_typahead=='1' ){
        
$doc->addScript(JURI::base(true) . '/modules/'.$moduleName.'/assets/js/bootstrap-typeahead.js');
    }
    

    if(
file_exists($cssFile)) {
        
$doc->addStylesheet(JURI::base(true) . '/templates/'.$doc->template.'/css/'$moduleName '.css');
    } else {
        
$doc->addStylesheet(JURI::base(true) . '/modules/'.$moduleName.'/assets/css/style.css');
    }

    
$modSPVMSearchHelper->ajaxRequest($max_search_suggest$module_id);
    require 
JModuleHelper::getLayoutPath($moduleName$params->get('layout''default'));

when I enter a search key, the first page shows the right results but from the second forward paging shows me the entire catalog.
I try to change method form in default page from POST to GET and i disable "Search Engine Friendly URLs" and "Adds Suffix to URL".
After this changes the search pagination works; but i need to activate "Search Engine Friendly URLs" and "Adds Suffix to URL" in my website.

Is it possible to disable "Search Engine Friendly URLs" and "Adds Suffix to URL" only for this specified module?
or you have any idea how to solve this problem?

Thank you

Ghost

What URL are you getting? You can disable SEF URL by removing JRoute from form action.

guardiano78

thank you for response.
With "Search Engine Friendly URLs" and "Adds Suffix to URL" i get this url: index.php/component/virtuemart/search.html
Without "Search Engine Friendly URLs" and "Adds Suffix to URL" i get this url: index.php?option=com_virtuemart&view=category&search=true&limitstart=0

thanks!

guardiano78

I tried to replace this string:

<form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&search=true&limitstart=0' ); ?>" method="post">

with this:

<form action="index.php" method="get">

but the issue for pagination does not been solved :-(


Ghost


guardiano78

the link is www.eyenet.it

i change the form from POST to GET

<form action="index.php" method="get">

click on magnifier to see the module and for example, try to write "samsung" and select the category "Lettori sim".
In the first page we have 30 element of 38 (it is correct); try to go in the next page from pagination and number of total products change and it display also other products.