my earlier issue was solved which spoke about base_url duplication in CodeIgniter. However, after editing base_url() as base_url = "http://example.com/myapp/", form submission does not load my thank you page. I have checked it with Firebug, there is a Response: 200 OK coming. But my view register-done.php does not load no matter what I do. The form just stays there. Doesn't move, though the data goes to database and registered. Before this fix, it was working fine. here is the html of form-submission:
<div class="section-title">Personal Details</div>
<form id="profile-image-form" method="post" action="<?= base_url() ?>signup" enctype="multipart/form-data">
<img src="<?= asset_url() ?>css/images/grey-bg.png" width="128" class="profile-pic"/>
<button type="button" id="upload-supplier-user-image-button" class="no-btn-style" onclick="$('#profile_image').click()">Upload User Image</button>
<img style="display:none; width: 35px;" src="<?= asset_url()?>images/upload-loading.gif" id="supplier-profile-upload-gif"/>
<input type="file" name="image" id="profile_image" style="display: none"/>
</form>
<form id="register-company-form" method="post" action="<?= base_url() ?>signup/supplier" enctype="text/plain">
<input type="hidden" name="image" id="image" value=""/>
<input type="text" id="first_name" name="first_name" class="text-field"/>
<input type="text" id="last_name" name="last_name" class="text-field"/>
<input type="text" id="user_name" name="user_name" class="text-field"/>
<input type="email" id="personal_email" name="personal_email" class="text-field"/>
<input type="password" id="password" name="password" class="text-field"/>
<input type="password" id="confirm_password" name="confirm_password" class="text-field"/>
<input type="text" id="job" name="job" class="text-field"/>
<input type="submit" name="sign-up-personal" id="sign-up-personal" class="btn-purple supplier-login-btn" value="Sign Up"/>
<input type="text" id="company_name" name="company_name" class="text-field"/>
<input type="text" id="address_one" name="address_one" class="text-field"/>
<input type="text" id="address_two" name="address_two" class="text-field"/>
<input id="autocomplete" placeholder="Enter your city" type="text" class="text-field" required autocomplete="off"/>
<input id="city" type="hidden" value="" name="city" required>
<input id="country" type="hidden" value="" name="country" required>
<button type="button" class="btn-purple supplier-login-btn" onclick="$('#company_logo_file').click()">Browse</button>
<input type="hidden" id="company_logo" name="company_logo" value=""/>
<textarea id="company_description" name="company_description" class="textarea-field"></textarea>
<input type="text" id="company_website" name="company_website" class="text-field"/>
<input type="email" id="company_email" name="company_email" class="text-field"/>
<input type="text" id="company_telephone" name="company_telephone" class="text-field"/>
<button type="button" class="btn-purple supplier-login-btn" onclick="$('#trade_license').click()">Browse</button>
<input type="file" id="trade_license" name="trade_license" class="text-field hidden" accept="application/pdf"/>
<input type="checkbox" name="terms" value="yes"/> By Signing up, I agree to <span class="terms-of-service">terms of service</span>
<input type="submit" name="sign-up" id="sign-up" class="btn-purple supplier-login-btn" value="Sign Up"/>
</form>
<form id="company_logo_form" method="post" action="" enctype="multipart/form-data">
<input type="file" style="display: none" name="company_logo_file" id="company_logo_file" accept="image/*"/>
</form>
<script type="text/javascript">
$.validator.addMethod("valueNotEquals", function(value, element, arg){
return arg != value;
}, "Value must not equal arg.");
var validator = $('#register-company-form').validate({
/* some validation */
submitHandler: function(form) {
var formData = new FormData($(form)[0]);
$.ajax({
type: $(form).attr('method'),
url: $(form).attr('action'),
data: formData,
dataType : 'json',
cache: false,
contentType: false,
processData: false
})
.done(function (response) {
window.location.href = '<?= base_url() ?>supplier/successful';
});
});
</script>
and here is the signup controller. I have changed nothing, but it stopped sending form to the database :( Any help will be highly appreciated. #DFriend
<?php
class Signup extends CI_Controller {
private $return_data = NULL;
private $return_status = 200;
private $return_message = NULL;
public function index(){
$this->load->model('CaptchaModel');
$this->load->helper('Captcha');
$cid = $this->input->post('cid');
$captcha = $this->input->post('captcha');
$captcha_exist = $this->CaptchaModel->check_captcha($captcha, $cid);
if($captcha_exist)
{
$this->load->model('RegisterModel');
$image = parent::check_user_input($this->input->post('image'));
$title = $this->input->post('title');
$first_name = $this->input->post('first_name');
$last_name = $this->input->post('last_name');
$user_name = $this->input->post('user_name');
$email = $this->input->post('email');
$password = $this->input->post('password');
$gender = $this->input->post('gender');
$mobile = parent::check_user_input($this->input->post('mobile'));
$dob_day = parent::check_user_input($this->input->post('dob_day'));
$dob_month = parent::check_user_input($this->input->post('dob_month'));
$dob_year = parent::check_user_input($this->input->post('dob_year'));
if($dob_day != '' && $dob_month != '' && $dob_year != ''){
$date_of_birth = new DateTime($dob_year . '-' . $dob_month . '-' . $dob_day);
}
else
{
$date_of_birth = '';
}
$country = parent::check_user_input($this->input->post('country'));
$city = parent::check_user_input($this->input->post('city'));
$interests = $this->input->post('interests');
$habits = $this->input->post('habits');
$comment = parent::check_user_input($this->input->post('comments'));
$newsletter = parent::check_user_input($this->input->post('newsletter'));
$registration = $this->RegisterModel->register($image, $title, $first_name, $last_name, $user_name, $email, $password, $mobile, $date_of_birth, $country, $city, $interests, $habits, $comment, $newsletter, $gender);
if($registration == -1)
{
$this->return_status = 400;
parent::returnJson($this->return_data, $this->return_status, $this->return_message);
}
elseif
($registration == -2)
{
$this->return_status = 401;
parent::returnJson($this->return_data, $this->return_status, $this->return_message);
}elseif
($registration){
$this->load->library('session');
$user_data = array('login' => 1,'uid' => $registration);
$this->session->set_userdata($user_data);
parent::returnJson($this->return_data, $this->return_status, $this->return_message);
}
else
{
$this->return_status = 500;
parent::returnJson($this->return_data, $this->return_status, $this->return_message);
}
}
else
{
$this->return_status = 600;
parent::returnJson($this->return_data, $this->return_status, $this->return_message);
}
}
public function supplier()
{
$file_element_name = 'trade_license';
$this->load->model('RegisterModel');
$profile_image_form = $this->input->post('image');
$title = $this->input->post('title');
$first_name = $this->input->post('first_name');
$last_name = $this->input->post('last_name');
$user_name = $this->input->post('user_name');
$email = $this->input->post('personal_email');
$password = $this->input->post('password');
$job = $this->input->post('job');
$company_name = $this->input->post('company_name');
$address_one = $this->input->post('address_one');
$address_two = $this->input->post('address_two');
$country = $this->input->post('country');
$city = $this->input->post('city');
$company_description = $this->input->post('company_description');
$company_website = $this->input->post('company_website');
$company_email = $this->input->post('company_email');
$company_telephone = $this->input->post('company_telephone');
$company_logo = $this->input->post('company_logo');
$trade_license = '';
$config['upload_path'] = './assets/license/';
$config['allowed_types'] = 'pdf';
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
if (!$this->upload->do_upload($file_element_name))
{
$status = 'error';
$msg = $this->upload->display_errors('', '');
}
else
{
$data = $this->upload->data();
$status = "success";
$msg = '';
$trade_license = $data['file_name'];
}
$profile_image = $profile_image_form;
$config['upload_path'] = './assets/profile/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['remove_spaces'] = TRUE;
$this->load->library('upload', $config);
if (!$this->upload->do_upload($profile_image_form))
{
$status = 'error';
$msg = $this->upload->display_errors('', '');
}
else
{
$data = $this->upload->data();
$status = "success";
$msg = '';
$profile_image = $data['file_name'];
}
$email_found = $this->db->get_where("supplier_user", array("company_email" => $email));
if($email_found->result_id->num_rows > 0) {
parent::returnJson($this->return_data, 401, $this->return_message);
}
else
{
$email_found_2 = $this->db->get_where("supplier_user", array("email" => $email));
if($email_found_2->result_id->num_rows > 0) {
parent::returnJson($this->return_data, 402, $this->return_message);
}
else
{
$username_found = $this->db->get_where("supplier_user", array("user_name" => $user_name));
if($username_found->result_id->num_rows > 0) {
parent::returnJson($this->return_data, 403, $this->return_message); }
else
{
$this->RegisterModel->register_supplier($profile_image, $title, $first_name, $last_name, $user_name, $email, $password, $job, $company_name, $address_one, $address_two, $country, $city, $company_description, $company_website, $company_email, $company_telephone, $company_logo, $trade_license);
parent::returnJson($this->return_data, $this->return_status, $this->return_message);
}
}
}
}
}
it seems like there is an issue with your .htaccess file. if you do not want to remove index.php file from the url you can use site_url() instead of base_url.Here is the difference b/w both
base_url() = http://yourwebsite.com/
whereas
site_url() = http://yourwebsite.com/index.php
to remove index.php file from url put this code in .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
read this tutorial for more
http://w3code.in/2015/09/how-to-remove-index-php-file-from-codeigniter-url/
I used mod bycategory to display products on homepage
Now, im' want display description category(don't product) (on homepage)
Code catalog/controller/module/bycategory.php
<?php
class ControllerModuleBycategory extends Controller {
public function index($setting) {
$this->load->language('module/bycategory');
$data['heading_title'] = $setting['name'];
$data['text_tax'] = $this->language->get('text_tax');
$data['button_cart'] = $this->language->get('button_cart');
$data['button_wishlist'] = $this->language->get('button_wishlist');
$data['button_compare'] = $this->language->get('button_compare');
$this->load->model('catalog/product');
$this->load->model('tool/image');
$data['products'] = array();
$filter_data = array(
'sort' => 'p.date_added',
'order' => 'DESC',
'start' => 0,
'limit' => $setting['limit'],
'filter_category_id'=>$setting['category']
);
$data['type'] = $setting['type'];
$results = $this->model_catalog_product->getProducts($filter_data);
if ($results) {
foreach ($results as $result) {
if ($result['image']) {
$image = $this->model_tool_image->resize($result['image'], $setting['width'], $setting['height']);
} else {
$image = $this->model_tool_image->resize('placeholder.png', $setting['width'], $setting['height']);
}
if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
$price = $this->currency->format($this->tax->calculate($result['price'], $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$price = false;
}
if ((float)$result['special']) {
$special = $this->currency->format($this->tax->calculate($result['special'], $result['tax_class_id'], $this->config->get('config_tax')));
} else {
$special = false;
}
if ($this->config->get('config_tax')) {
$tax = $this->currency->format((float)$result['special'] ? $result['special'] : $result['price']);
} else {
$tax = false;
}
if ($this->config->get('config_review_status')) {
$rating = $result['rating'];
} else {
$rating = false;
}
$data['products'][] = array(
'product_id' => $result['product_id'],
'thumb' => $image,
'name' => $result['name'],
'description' => utf8_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('config_product_description_length')) . '..',
'price' => $price,
'special' => $special,
'tax' => $tax,
'rating' => $rating,
'href' => $this->url->link('product/product', 'product_id=' . $result['product_id']),
);
}
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/bycategory.tpl')) {
return $this->load->view($this->config->get('config_template') . '/template/module/bycategory.tpl', $data);
} else {
return $this->load->view('default/template/module/bycategory.tpl', $data);
}
}
}
}
And code catalog/view/theme/default/template/module/bycategory.tpl
<?php foreach ($products as $product) { ?>
<?php
if($type=="vertical"){
?>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<?php
}else{
?>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<?php
}
?>
<div class="product-thumb transition">
<div class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>" class="img-responsive" /></div>
<div class="caption">
<h4><?php echo $product['name']; ?></h4>
<?php if ($product['rating']) { ?>
<div class="rating">
<?php for ($i = 1; $i <= 5; $i++) { ?>
<?php if ($product['rating'] < $i) { ?>
<span class="fa fa-stack"><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } else { ?>
<span class="fa fa-stack"><i class="fa fa-star fa-stack-2x"></i><i class="fa fa-star-o fa-stack-2x"></i></span>
<?php } ?>
<?php } ?>
</div>
<?php } ?>
<?php if ($product['price']) { ?>
<p class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-new"><?php echo $product['special']; ?></span> <span class="price-old"><?php echo $product['price']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
</p>
<?php } ?>
</div>
<div class="button-group">
<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
<button type="button" data-toggle="tooltip" title="<?php echo $button_wishlist; ?>" onclick="wishlist.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-heart"></i></button>
<button type="button" data-toggle="tooltip" title="<?php echo $button_compare; ?>" onclick="compare.add('<?php echo $product['product_id']; ?>');"><i class="fa fa-exchange"></i></button>
</div>
</div>
</div>
<?php } ?>
</div>
How to display [![description for category][1]][1] (by category in homepage)?
Help me!
Link demo http://duhocaaumy.com/demo.jpg
Try this solution,
Add below code in catalog/controller/module/bycategory.php
$category_info = $this->model_catalog_category->getCategory($setting['category']);
$data['description'] = html_entity_decode($category_info['description'], ENT_QUOTES, 'UTF-8');
Go to catalog/view/theme/default/template/module/bycategory.tpl
Add below code where you want to display category description
<?php echo $description; ?>
When I submit search results on my site it loads accurate results with the correct number of products displayed... When I go down to the pagination links at the bottom they show the correct links when hovered over them... However when I click on them it just reloads the page I'm already at AND it adds # to the end of the URL string.... The code appears to be correct, my initial feeling is that this maybe because of the SEO URLS I have enabled in opencart, and the HTACCESS edits I have made....
Here is an example: http://www.justicejewelers.com/index.php?route=product/search&filter_name=gold
HTACCESS:
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]
Search.php:
$pagination = new Pagination();
$pagination->total = $product_total;
$pagination->page = $page;
$pagination->limit = $limit;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('product/search', $url . '&page={page}');
Search.TPL:
<?php echo $header; ?>
<?php echo $content_top; ?>
<div class="breadcrumb">
<?php foreach ($breadcrumbs as $breadcrumb) { ?>
<?php echo $breadcrumb['separator']; ?>
<a href="<?php echo $breadcrumb['href']; ?>">
<?php echo $breadcrumb['text']; ?>
</a>
<?php } ?>
</div>
<header class="heading">
<h1><?php echo $heading_title; ?></h1>
<div id="notification"></div>
</header>
<?php
if ($column_left || $column_right) { $main = "span9"; }
else { $main = "span12"; }
?>
<div class="row-fluid">
<?php echo $column_left; ?>
<section id="maincontent" class="<?php echo $main; ?> search listing" role="main">
<div class="mainborder">
<?php if ($column_left) { ?>
<div id="toggle_sidebar"></div>
<?php } ?>
<div class="search-criteria">
<div class="contentset center">
<h4 class="inner">
<span><?php echo $text_critea; ?></span>
</h4>
</div>
<div class="controls">
<input type="search" name="filter_name" id="filter_name" value="<?php echo $filter_name; ?>" class="search-box span6" placeholder="Search" />
</div>
<select name="filter_category_id" class="filter-category span4">
<option value="0"><?php echo $text_category; ?></option>
<?php foreach ($categories as $category_1) { ?>
<?php if ($category_1['category_id'] == $filter_category_id) { ?>
<option value="<?php echo $category_1['category_id']; ?>" selected="selected"><?php echo $category_1['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $category_1['category_id']; ?>"><?php echo $category_1['name']; ?></option>
<?php } ?>
<?php foreach ($category_1['children'] as $category_2) { ?>
<?php if ($category_2['category_id'] == $filter_category_id) { ?>
<option value="<?php echo $category_2['category_id']; ?>" selected="selected"> - <?php echo $category_2['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $category_2['category_id']; ?>"> - <?php echo $category_2['name']; ?></option>
<?php } ?>
<?php foreach ($category_2['children'] as $category_3) { ?>
<?php if ($category_3['category_id'] == $filter_category_id) { ?>
<option value="<?php echo $category_3['category_id']; ?>" selected="selected"> - <?php echo $category_3['name']; ?></option>
<?php } else { ?>
<option value="<?php echo $category_3['category_id']; ?>"> - <?php echo $category_3['name']; ?></option>
<?php } ?>
<?php } ?>
<?php } ?>
<?php } ?>
</select>
<div class="controls">
<label class="checkbox inline">
<?php if ($filter_sub_category) { ?>
<input type="checkbox" name="filter_sub_category" value="1" id="sub_category" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="filter_sub_category" value="1" id="sub_category" />
<?php } ?>
<?php echo $text_sub_category; ?>
</label>
<label class="checkbox inline">
<?php if ($filter_description) { ?>
<input type="checkbox" name="filter_description" value="1" id="description" checked="checked" />
<?php } else { ?>
<input type="checkbox" name="filter_description" value="1" id="description" />
<?php } ?>
<?php echo $entry_description; ?>
</label>
</div>
<div class="buttons">
<input type="button" value="<?php echo $button_search; ?>" id="button-search" class="btn btn-inverse" />
</div>
</div>
<div class="contentset center">
<h4 class="inner">
<span><?php echo $text_search; ?></span>
</h4>
</div>
<!-- Products
============================== -->
<?php if ($products) { ?>
<!-- Grid/Lis view, filters
============================== -->
<div class="product-filter">
<div class="btn-group display" data-toggle="buttons-radio">
<button id="grid" class="btn btn-mini" title="<?php echo $text_grid; ?>" onclick="display('grid');"><i class="icon-th"></i></button>
<button id="list" class="btn btn-mini" title="<?php echo $text_list; ?>" onclick="display('list');"><i class="icon-list"></i></button>
</div>
<span class="product-compare"><?php echo $text_compare; ?></span>
<div class="list-options">
<div class="sort">
<?php echo $text_sort; ?>
<select onchange="location = this.value;">
<?php foreach ($sorts as $sorts) { ?>
<?php if ($sorts['value'] == $sort . '-' . $order) { ?>
<option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
<?php } else { ?>
<option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="limit">
<?php echo $text_limit; ?>
<select onchange="location = this.value;">
<?php foreach ($limits as $limits) { ?>
<?php if ($limits['value'] == $limit) { ?>
<option value="<?php echo $limits['href']; ?>" selected="selected">
<?php echo $limits['text']; ?>
</option>
<?php } else { ?>
<option value="<?php echo $limits['href']; ?>">
<?php echo $limits['text']; ?>
</option>
<?php } ?>
<?php } ?>
</select>
</div>
</div>
</div>
<!-- Product list (Default to Grid)
============================== -->
<div class="product-grid row-fluid">
<?php
$counter=0;
foreach ($products as $product) {
if ($counter == 0 ) $xclass = 'alpha';
else if (($counter+12) % 12 == 0 ) $xclass = 'alpha4 alpha3';
else if (($counter+4) % 4 == 0 ) $xclass = 'alpha4';
else if (($counter+3) % 3 == 0 ) $xclass = 'alpha3';
else $xclass = '';
if (($counter+2) % 2 == 0 ) $xclass .= ' odd';
?>
<div class="grid-box <?php echo $xclass; ?>">
<div class="inner">
<?php if ($product['price'] && $product['special']) { ?>
<span class="onsale">
<?php $this->language->load('module/sellegance');
echo $this->language->get('text_onsale'); ?>
</span>
<?php } ?>
<?php if ($product['thumb']) { ?>
<div class="image">
<img src="<?php echo $product['thumb']; ?>" title="<?php echo $product['name']; ?>" alt="<?php echo $product['name']; ?>" />
</div>
<?php } ?>
<div class="name">
<?php echo $product['name']; ?>
</div>
<?php if ($product['rating']) { ?>
<div class="rating">
<img src="catalog/view/theme/sellegance/images/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" />
</div>
<?php } ?>
<div class="description"><?php echo $product['description']; ?></div>
<?php if ($product['price']) { ?>
<div class="price">
<?php if (!$product['special']) { ?>
<?php echo $product['price']; ?>
<?php } else { ?>
<span class="price-old"><?php echo $product['price']; ?></span>
<span class="price-new"><?php echo $product['special']; ?></span>
<?php } ?>
<?php if ($product['tax']) { ?>
<br />
<span class="price-tax"><?php echo $text_tax; ?> <?php echo $product['tax']; ?></span>
<?php } ?>
</div>
<?php } ?>
<div class="actions">
<div class="cart">
<input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="btn btn-cart btn-small" />
</div>
<div class="wishlist"><a onclick="addToWishList('<?php echo $product['product_id']; ?>');"><?php echo $button_wishlist; ?></a></div>
<div class="compare"><a onclick="addToCompare('<?php echo $product['product_id']; ?>');"><?php echo $button_compare; ?></a></div>
</div>
</div>
</div>
<?php $counter++; } ?>
</div> <!-- .produc-grid -->
<div class="paginate"><?php echo $pagination; ?></div>
<?php } else { ?>
<div class="content empty white">
<div class="alert warning"><?php echo $text_empty; ?><a class="close" data-dismiss="alert" href="#">×</a></div>
</div>
<?php } ?>
</div>
</section><!-- #maincontent -->
<?php echo $column_right; ?>
</div> <!-- .row -->
<?php echo $content_bottom; ?>
<script type="text/javascript">
jQuery('#maincontent input[name=\'filter_name\']').keydown(function(e) {
if (e.keyCode == 13) {
jQuery('.button-search').trigger('click');
}
});
jQuery('#button-search').bind('click', function() {
url = 'index.php?route=product/search';
var filter_name = jQuery('#maincontent input[name=\'filter_name\']').attr('value');
if (filter_name) {
url += '&filter_name=' + encodeURIComponent(filter_name);
}
var filter_category_id = jQuery('#maincontent select[name=\'filter_category_id\']').attr('value');
if (filter_category_id > 0) {
url += '&filter_category_id=' + encodeURIComponent(filter_category_id);
}
var filter_sub_category = jQuery('#maincontent input[name=\'filter_sub_category\']:checked').attr('value');
if (filter_sub_category) {
url += '&filter_sub_category=true';
}
var filter_description = jQuery('#maincontent input[name=\'filter_description\']:checked').attr('value');
if (filter_description) {
url += '&filter_description=true';
}
location = url;
});
</script>
The true question is why would this script in search:
<script type="text/javascript">
jQuery('#maincontent input[name=\'filter_name\']').keydown(function(e) {
if (e.keyCode == 13) {
jQuery('.button-search').trigger('click');
}
});
jQuery('#button-search').bind('click', function() {
url = 'index.php?route=product/search';
var filter_name = jQuery('#maincontent input[name=\'filter_name\']').attr('value');
if (filter_name) {
url += '&filter_name=' + encodeURIComponent(filter_name);
}
var filter_category_id = jQuery('#maincontent select[name=\'filter_category_id\']').attr('value');
if (filter_category_id > 0) {
url += '&filter_category_id=' + encodeURIComponent(filter_category_id);
}
var filter_sub_category = jQuery('#maincontent input[name=\'filter_sub_category\']:checked').attr('value');
if (filter_sub_category) {
url += '&filter_sub_category=true';
}
var filter_description = jQuery('#maincontent input[name=\'filter_description\']:checked').attr('value');
if (filter_description) {
url += '&filter_description=true';
}
location = url;
});
</script>
BE effected by bannerpack, and not work without it?
Here is the code for Banner Pack:
(function($){var NivoSlider=function(element,options){var settings=$.extend({},$.fn.nivoSlider.defaults,options);var vars={currentSlide:0,currentImage:'',totalSlides:0,randAnim:'',running:false,paused:false,stop:false};var slider=$(element);slider.data('nivo:vars',vars);slider.css('position','relative');slider.addClass('nivoSlider');var kids=slider.children();kids.each(function(){var child=$(this);var link='';if(!child.is('img')){if(child.is('a')){child.addClass('nivo-imageLink');link=child;}
child=child.find('img:first');}
var childWidth=child.width();if(childWidth==0)childWidth=child.attr('width');var childHeight=child.height();if(childHeight==0)childHeight=child.attr('height');if(childWidth>slider.width()){slider.width(childWidth);}
if(childHeight>slider.height()){slider.height(childHeight);}
if(link!=''){link.css('display','none');}
child.css('display','none');vars.totalSlides++;});if(settings.startSlide>0){if(settings.startSlide>=vars.totalSlides)settings.startSlide=vars.totalSlides-1;vars.currentSlide=settings.startSlide;}
if($(kids[vars.currentSlide]).is('img')){vars.currentImage=$(kids[vars.currentSlide]);}else{vars.currentImage=$(kids[vars.currentSlide]).find('img:first');}
if($(kids[vars.currentSlide]).is('a')){$(kids[vars.currentSlide]).css('display','block');}
slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');slider.append($('<div class="nivo-caption"><p></p></div>').css({display:'none',opacity:settings.captionOpacity}));var processCaption=function(settings){var nivoCaption=$('.nivo-caption',slider);if(vars.currentImage.attr('title')!=''&&vars.currentImage.attr('title')!=undefined){var title=vars.currentImage.attr('title');if(title.substr(0,1)=='#')title=$(title).html();if(nivoCaption.css('display')=='block'){nivoCaption.find('p').fadeOut(settings.animSpeed,function(){$(this).html(title);$(this).fadeIn(settings.animSpeed);});}else{nivoCaption.find('p').html(title);}
nivoCaption.fadeIn(settings.animSpeed);}else{nivoCaption.fadeOut(settings.animSpeed);}}
processCaption(settings);var timer=0;if(!settings.manualAdvance&&kids.length>1){timer=setInterval(function(){nivoRun(slider,kids,settings,false);},settings.pauseTime);}
if(settings.directionNav){slider.append('<div class="ban_direction"><a class="nivo-prevNav">'+settings.prevText+'</a><a class="nivo-nextNav">'+settings.nextText+'</a></div>');if(settings.directionNavHide){$('.ban_direction',slider).hide();slider.hover(function(){$('.ban_direction',slider).show();},function(){$('.ban_direction',slider).hide();});}
$('a.nivo-prevNav',slider).live('click',function(){if(vars.running)return false;clearInterval(timer);timer='';vars.currentSlide-=2;nivoRun(slider,kids,settings,'prev');});$('a.nivo-nextNav',slider).live('click',function(){if(vars.running)return false;clearInterval(timer);timer='';nivoRun(slider,kids,settings,'next');});}
if(settings.controlNav){var nivoControl=$('<div class="banner_control"></div>');slider.append(nivoControl);for(var i=0;i<kids.length;i++){if(settings.controlNavThumbs){var child=kids.eq(i);if(!child.is('img')){child=child.find('img:first');}
if(settings.controlNavThumbsFromRel){nivoControl.append('<a class="ban_control" rel="'+i+'"><img src="'+child.attr('rel')+'" alt="" /></a>');}else{nivoControl.append('<a class="ban_control" rel="'+i+'"><img src="'+child.attr('src').replace(settings.controlNavThumbsSearch,settings.controlNavThumbsReplace)+'" alt="" /></a>');}}else{nivoControl.append('<a class="ban_control" rel="'+i+'">'+(i+1)+'</a>');}}
$('.banner_control a:eq('+vars.currentSlide+')',slider).addClass('active');$('.banner_control a',slider).live('click',function(){if(vars.running)return false;if($(this).hasClass('active'))return false;clearInterval(timer);timer='';slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');vars.currentSlide=$(this).attr('rel')-1;nivoRun(slider,kids,settings,'control');});}
if(settings.keyboardNav){$(window).keypress(function(event){if(event.keyCode=='37'){if(vars.running)return false;clearInterval(timer);timer='';vars.currentSlide-=2;nivoRun(slider,kids,settings,'prev');}
if(event.keyCode=='39'){if(vars.running)return false;clearInterval(timer);timer='';nivoRun(slider,kids,settings,'next');}});}
if(settings.pauseOnHover){slider.hover(function(){vars.paused=true;clearInterval(timer);timer='';},function(){vars.paused=false;if(timer==''&&!settings.manualAdvance){timer=setInterval(function(){nivoRun(slider,kids,settings,false);},settings.pauseTime);}});}
slider.bind('nivo:animFinished',function(){vars.running=false;$(kids).each(function(){if($(this).is('a')){$(this).css('display','none');}});if($(kids[vars.currentSlide]).is('a')){$(kids[vars.currentSlide]).css('display','block');}
if(timer==''&&!vars.paused&&!settings.manualAdvance){timer=setInterval(function(){nivoRun(slider,kids,settings,false);},settings.pauseTime);}
settings.afterChange.call(this);});var createSlices=function(slider,settings,vars){for(var i=0;i<settings.slices;i++){var sliceWidth=Math.round(slider.width()/settings.slices);if(i==settings.slices-1){slider.append($('<div class="banner-slice"></div>').css({left:(sliceWidth*i)+'px',width:(slider.width()-(sliceWidth*i))+'px',height:'0px',opacity:'0',background:'url("'+vars.currentImage.attr('src')+'") no-repeat -'+((sliceWidth+(i*sliceWidth))-sliceWidth)+'px 0%'}));}else{slider.append($('<div class="banner-slice"></div>').css({left:(sliceWidth*i)+'px',width:sliceWidth+'px',height:'0px',opacity:'0',background:'url("'+vars.currentImage.attr('src')+'") no-repeat -'+((sliceWidth+(i*sliceWidth))-sliceWidth)+'px 0%'}));}}}
var createBoxes=function(slider,settings,vars){var boxWidth=Math.round(slider.width()/settings.boxCols);var boxHeight=Math.round(slider.height()/settings.boxRows);for(var rows=0;rows<settings.boxRows;rows++){for(var cols=0;cols<settings.boxCols;cols++){if(cols==settings.boxCols-1){slider.append($('<div class="bannar-box"></div>').css({opacity:0,left:(boxWidth*cols)+'px',top:(boxHeight*rows)+'px',width:(slider.width()-(boxWidth*cols))+'px',height:boxHeight+'px',background:'url("'+vars.currentImage.attr('src')+'") no-repeat -'+((boxWidth+(cols*boxWidth))-boxWidth)+'px -'+((boxHeight+(rows*boxHeight))-boxHeight)+'px'}));}else{slider.append($('<div class="bannar-box"></div>').css({opacity:0,left:(boxWidth*cols)+'px',top:(boxHeight*rows)+'px',width:boxWidth+'px',height:boxHeight+'px',background:'url("'+vars.currentImage.attr('src')+'") no-repeat -'+((boxWidth+(cols*boxWidth))-boxWidth)+'px -'+((boxHeight+(rows*boxHeight))-boxHeight)+'px'}));}}}}
var nivoRun=function(slider,kids,settings,nudge){var vars=slider.data('nivo:vars');if(vars&&(vars.currentSlide==vars.totalSlides-1)){settings.lastSlide.call(this);}
if((!vars||vars.stop)&&!nudge)return false;settings.beforeChange.call(this);if(!nudge){slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');}else{if(nudge=='prev'){slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');}
if(nudge=='next'){slider.css('background','url("'+vars.currentImage.attr('src')+'") no-repeat');}}
vars.currentSlide++;if(vars.currentSlide==vars.totalSlides){vars.currentSlide=0;settings.slideshowEnd.call(this);}
if(vars.currentSlide<0)vars.currentSlide=(vars.totalSlides-1);if($(kids[vars.currentSlide]).is('img')){vars.currentImage=$(kids[vars.currentSlide]);}else{vars.currentImage=$(kids[vars.currentSlide]).find('img:first');}
if(settings.controlNav){$('.banner_control a',slider).removeClass('active');$('.banner_control a:eq('+vars.currentSlide+')',slider).addClass('active');}
processCaption(settings);$('.banner-slice',slider).remove();$('.bannar-box',slider).remove();if(settings.effect=='random'){var anims=new Array('fade');vars.randAnim=anims[Math.floor(Math.random()*(anims.length+1))];if(vars.randAnim==undefined)vars.randAnim='fade';}
if(settings.effect.indexOf(',')!=-1){var anims=settings.effect.split(',');vars.randAnim=anims[Math.floor(Math.random()*(anims.length))];if(vars.randAnim==undefined)vars.randAnim='fade';}
vars.running=true;if(settings.effect=='sliceDown'||settings.effect=='sliceDownRight'||vars.randAnim=='sliceDownRight'||settings.effect=='sliceDownLeft'||vars.randAnim=='sliceDownLeft'){createSlices(slider,settings,vars);var timeBuff=0;var i=0;var slices=$('.banner-slice',slider);if(settings.effect=='sliceDownLeft'||vars.randAnim=='sliceDownLeft')slices=$('.banner-slice',slider)._reverse();slices.each(function(){var slice=$(this);slice.css({'top':'0px'});if(i==settings.slices-1){setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=50;i++;});}
else if(settings.effect=='sliceUp'||settings.effect=='sliceUpRight'||vars.randAnim=='sliceUpRight'||settings.effect=='sliceUpLeft'||vars.randAnim=='sliceUpLeft'){createSlices(slider,settings,vars);var timeBuff=0;var i=0;var slices=$('.banner-slice',slider);if(settings.effect=='sliceUpLeft'||vars.randAnim=='sliceUpLeft')slices=$('.banner-slice',slider)._reverse();slices.each(function(){var slice=$(this);slice.css({'bottom':'0px'});if(i==settings.slices-1){setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=50;i++;});}
else if(settings.effect=='sliceUpDown'||settings.effect=='sliceUpDownRight'||vars.randAnim=='sliceUpDown'||settings.effect=='sliceUpDownLeft'||vars.randAnim=='sliceUpDownLeft'){createSlices(slider,settings,vars);var timeBuff=0;var i=0;var v=0;var slices=$('.banner-slice',slider);if(settings.effect=='sliceUpDownLeft'||vars.randAnim=='sliceUpDownLeft')slices=$('.banner-slice',slider)._reverse();slices.each(function(){var slice=$(this);if(i==0){slice.css('top','0px');i++;}else{slice.css('bottom','0px');i=0;}
if(v==settings.slices-1){setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){slice.animate({height:'100%',opacity:'1.0'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=50;v++;});}
else if(settings.effect=='fold'||vars.randAnim=='fold'){createSlices(slider,settings,vars);var timeBuff=0;var i=0;$('.banner-slice',slider).each(function(){var slice=$(this);var origWidth=slice.width();slice.css({top:'0px',height:'100%',width:'0px'});if(i==settings.slices-1){setTimeout(function(){slice.animate({width:origWidth,opacity:'1.0'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){slice.animate({width:origWidth,opacity:'1.0'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=50;i++;});}
else if(settings.effect=='fade'||vars.randAnim=='fade'){createSlices(slider,settings,vars);var firstSlice=$('.banner-slice:first',slider);firstSlice.css({'height':'100%','width':slider.width()+'px'});firstSlice.animate({opacity:'1.0'},(settings.animSpeed*2),'',function(){slider.trigger('nivo:animFinished');});}
else if(settings.effect=='slideInRight'||vars.randAnim=='slideInRight'){createSlices(slider,settings,vars);var firstSlice=$('.banner-slice:first',slider);firstSlice.css({'height':'100%','width':'0px','opacity':'1'});firstSlice.animate({width:slider.width()+'px'},(settings.animSpeed*2),'',function(){slider.trigger('nivo:animFinished');});}
else if(settings.effect=='slideInLeft'||vars.randAnim=='slideInLeft'){createSlices(slider,settings,vars);var firstSlice=$('.banner-slice:first',slider);firstSlice.css({'height':'100%','width':'0px','opacity':'1','left':'','right':'0px'});firstSlice.animate({width:slider.width()+'px'},(settings.animSpeed*2),'',function(){firstSlice.css({'left':'0px','right':''});slider.trigger('nivo:animFinished');});}
else if(settings.effect=='boxRandom'||vars.randAnim=='boxRandom'){createBoxes(slider,settings,vars);var totalBoxes=settings.boxCols*settings.boxRows;var i=0;var timeBuff=0;var boxes=shuffle($('.bannar-box',slider));boxes.each(function(){var box=$(this);if(i==totalBoxes-1){setTimeout(function(){box.animate({opacity:'1'},settings.animSpeed,'',function(){slider.trigger('nivo:animFinished');});},(100+timeBuff));}else{setTimeout(function(){box.animate({opacity:'1'},settings.animSpeed);},(100+timeBuff));}
timeBuff+=20;i++;});}
else if(settings.effect=='boxRain'||vars.randAnim=='boxRain'||settings.effect=='boxRainReverse'||vars.randAnim=='boxRainReverse'||settings.effect=='boxRainGrow'||vars.randAnim=='boxRainGrow'||settings.effect=='boxRainGrowReverse'||vars.randAnim=='boxRainGrowReverse'){createBoxes(slider,settings,vars);var totalBoxes=settings.boxCols*settings.boxRows;var i=0;var timeBuff=0;var rowIndex=0;var colIndex=0;var box2Darr=new Array();box2Darr[rowIndex]=new Array();var boxes=$('.bannar-box',slider);if(settings.effect=='boxRainReverse'||vars.randAnim=='boxRainReverse'||settings.effect=='boxRainGrowReverse'||vars.randAnim=='boxRainGrowReverse'){boxes=$('.bannar-box',slider)._reverse();}
boxes.each(function(){box2Darr[rowIndex][colIndex]=$(this);colIndex++;if(colIndex==settings.boxCols){rowIndex++;colIndex=0;box2Darr[rowIndex]=new Array();}});for(var cols=0;cols<(settings.boxCols*2);cols++){var prevCol=cols;for(var rows=0;rows<settings.boxRows;rows++){if(prevCol>=0&&prevCol<settings.boxCols){(function(row,col,time,i,totalBoxes){var box=$(box2Darr[row][col]);var w=box.width();var h=box.height();if(settings.effect=='boxRainGrow'||vars.randAnim=='boxRainGrow'||settings.effect=='boxRainGrowReverse'||vars.randAnim=='boxRainGrowReverse'){box.width(0).height(0);}
if(i==totalBoxes-1){setTimeout(function(){box.animate({opacity:'1',width:w,height:h},settings.animSpeed/1.3,'',function(){slider.trigger('nivo:animFinished');});},(100+time));}else{setTimeout(function(){box.animate({opacity:'1',width:w,height:h},settings.animSpeed/1.3);},(100+time));}})(rows,prevCol,timeBuff,i,totalBoxes);i++;}
prevCol--;}
timeBuff+=100;}}}
var shuffle=function(arr){for(var j,x,i=arr.length;i;j=parseInt(Math.random()*i),x=arr[--i],arr[i]=arr[j],arr[j]=x);return arr;}
var trace=function(msg){if(this.console&&typeof console.log!="undefined")
console.log(msg);}
this.stop=function(){if(!$(element).data('nivo:vars').stop){$(element).data('nivo:vars').stop=true;trace('Stop Slider');}}
this.start=function(){if($(element).data('nivo:vars').stop){$(element).data('nivo:vars').stop=false;trace('Start Slider');}}
settings.afterLoad.call(this);return this;};$.fn.nivoSlider=function(options){return this.each(function(key,value){var element=$(this);if(element.data('nivoslider'))return element.data('nivoslider');var nivoslider=new NivoSlider(this,options);element.data('nivoslider',nivoslider);});};$.fn.nivoSlider.defaults={effect:'random',slices:15,boxCols:8,boxRows:4,animSpeed:500,pauseTime:5000,startSlide:0,directionNav:true,directionNavHide:true,controlNav:true,controlNavThumbs:false,controlNavThumbsFromRel:false,controlNavThumbsSearch:'.jpg',controlNavThumbsReplace:'_thumb.jpg',keyboardNav:true,pauseOnHover:true,manualAdvance:false,captionOpacity:0.8,prevText:'Prev',nextText:'Next',beforeChange:function(){},afterChange:function(){},slideshowEnd:function(){},lastSlide:function(){},afterLoad:function(){}};$.fn._reverse = []._reverse||[].reverse;})(jQuery); jQuery.noConflict();
The problem is definitely a JavaScript problem. The URLs are alright thus there has to be some JavaScript messing up. Because there are tons of JavaScript files and libraries added to Your site/theme I was unable to identify the real problem, but if You turn off the javascript within Your browser and try to click on the pagination links You will see the pagination is working correctly.
I would suggest disabling one JavaScript include after another and refreshing the page (just by commenting out the lines within Your footer, header, or appropriate controllers) and checking the pagination. Finally You should be able to identify the one that causes the problem and we could then lead You to the happy ending.
I'm trying to create a user registration page for my site using Kohana 3.3 and Kostache as my template system.
I'm having a hard time getting to work the Form Validation to display validation errors on the same page. Right now when i click on the form submit button and sending all empty values in the form (username, email and password) all i get is the form to refresh, when I should be getting validation errors such as username is empty, email is empty etc (im using Model_Auth_User).
I have no clue what am I doing wrong.
Model:
class Model_User extends Model_Auth_User
{
public function rules()
{
return array(
'username' => array(
array('not_empty'),
array('alpha_dash'),
array('min_length', array(':value', 4)),
array('max_length', array(':value', 20)),
array(array($this, 'unique'), array('username', ':value')),
),
'email' => array(
array('not_empty'),
array('min_length', array(':value', 4)),
array('max_length', array(':value', 127)),
array('email'),
),
);
}
}
Controller:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_User extends Controller {
public function action_index()
{
}
public function action_login()
{
$renderer = Kostache_Layout::factory();
$this->response->body($renderer->render(new View_FrontEnd_User, 'frontend/login'));
}
public function action_signup()
{
$renderer = Kostache_Layout::factory();
$this->response->body($renderer->render(new View_FrontEnd_User, 'frontend/signup'));
}
public function action_createuser()
{
$signupView = new View_FrontEnd_User();
try {
$user = ORM::factory('User');
$user->username = $this->request->post('username');
$user->password = $this->request->post('password');
$user->email = $this->request->post('email');
$user->save();
}
catch (ORM_Validation_Exception $e)
{
$errors = $e->errors();
$signupView->errors = $errors;
}
$renderer = Kostache_Layout::factory();
$this->response->body($renderer->render(new View_FrontEnd_User, 'frontend/signup'));
}
}
View
<?php defined('SYSPATH') or die('No direct script access.');
class View_FrontEnd_User extends View_Main
{
public $errors = array();
}
signup.mustache
<p>
<form action="user/createuser" method="post">
<fieldset style="width: 20em;">
<legend>User Registration</legend>
<label>Enter your username</label>
<input type="text" name="username" />
<label for="username" class="error">
{{#errors}}{{username}}{{/errors}}
</label>
<label>Enter your password</label>
<input type="password" name="password" />
<label for="password" class="error">
{{#errors}}{{password}}{{/errors}}
</label>
<label>Email</label>
<input type="text" name="email" />
<input type="submit" value="Submit" class="nice blue radius button" />
</fieldset>
</form>
{{#errors}}{{.}}{{/errors}}
</p>
Thanks a lot in advance for any pointers you can give me.
I've spent hours on this and still can't get it working :(
Change
$this->response->body($renderer->render(new View_FrontEnd_User, 'frontend/signup'));
to
$this->response->body($renderer->render($signupView, 'frontend/signup'));