Odd problem with category listing module

  • Posts: 14
  • Thank you received: 0
12 years 6 months ago #79992

Hi

I'm having a problem with the category listing module when set to show "all direct sub categories".

http://compusale.cloudaccess.net/computer-parts-sale.html

On the "Categories" module to the left. That module always have the "Motherboard" category opened up (showing it's sub categories such as "AMD (FM1)"). No matter which category I click on, once the page loads up, the "motherboard" category will be opened again.

For example when I click on the "Opteron" category ( a sub category of "CPU"), it goes to a page displaying Opteron CPUs BUT the Categories listing module will have the "Motherboards" category open up again (instead of having CPU open up)

Is there any way to make the correct category open up? i.e. when I'm in "Opteron", the "CPU" category will open up instead of "Motherboards" category?

If not, is there anyway to make no categories open up by default?


Thanks

regards
Simon

Attachments:
Last edit: 12 years 6 months ago by simon2012.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 6 months ago #80059

Hi,

To edit this functionality, you have to edit the view "category / listing_list".
Here is some code which should unselect default category:

					?><script type="text/javascript">
						if (window.addEventListener)     { window.addEventListener('load', changeClass, false);  }
						else {  window.attachEvent('onload', changeClass);  }
						function changeClass()    {
							document.getElementById('<?php echo 'category_pane_'.$k; ?>').className="title pane-toggler";
						}
					</script><?php
Add it just after: "echo $this->tabs->endPanel();"

The following user(s) said Thank You: simon2012

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
12 years 6 months ago #80126

Thanks for the reply Xavier.

I can't seem to get that code to work (not sure if I'm putting it in the correct place). Can you please copy and paste the entire "category / listing_list" here?

Also my client wants the selected category to open by default. i.e. when in a sub category of "CPU", the CPU category will open. Is this possible?

Last edit: 12 years 6 months ago by simon2012.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
12 years 6 months ago #80185

Here is the entire file:

<?php
if(!empty($this->rows)){
	$pagination = $this->config->get('pagination','bottom');
	if(in_array($pagination,array('top','both')) && $this->params->get('show_limit') && $this->pageInfo->elements->total > $this->pageInfo->limit->value){ $this->pagination->form = '_top'; ?>
	<form action="<?php echo hikashop_currentURL();?>" method="post" name="adminForm_<?php echo $this->params->get('main_div_name').$this->category_selected;?>_top">
		<div class="hikashop_subcategories_pagination hikashop_subcategories_pagination_top">
		<?php echo $this->pagination->getListFooter($this->params->get('limit')); ?>
		<span class="hikashop_results_counter"><?php echo $this->pagination->getResultsCounter(); ?></span>
		</div>
		<input type="hidden" name="filter_order_<?php echo $this->params->get('main_div_name').$this->category_selected;?>" value="<?php echo $this->pageInfo->filter->order->value; ?>" />
		<input type="hidden" name="filter_order_Dir_<?php echo $this->params->get('main_div_name').$this->category_selected;?>" value="<?php echo $this->pageInfo->filter->order->dir; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>
	</form>
	<?php } ?>
	<div class="hikashop_subcategories">
	<?php

	$only_if_products = $this->params->get('only_if_products',0);
	switch($this->params->get('child_display_type')){
		case 'nochild':
		default:
			if(!empty($this->rows)){
			?>
				<ul class="hikashop_category_list<?php echo $this->params->get('ul_class_name'); ?>">
				<?php

					$width = (int)(100/$this->params->get('columns'));
					if(empty($width)){
						$width='';
					}else{
						$width='style="width:'.$width.'%;"';
					}
					$app =& JFactory::getApplication();
					$found = '';
					if(JRequest::getString('option')==HIKASHOP_COMPONENT && in_array(JRequest::getString('ctrl','category'),array('category','product'))){
						$found = $app->getUserState(HIKASHOP_COMPONENT.'.last_category_selected');
						foreach($this->rows as $row){
							if(JRequest::getString('ctrl','category')=='product'&&JRequest::getString('task','listing')=='show'){
								$cid = JRequest::getInt('category_pathway',0);
							}else{
								$cid = JRequest::getInt('cid',0);
							}
							if($cid == $row->category_id){
								$found=$row->category_id;
								$app->setUserState(HIKASHOP_COMPONENT.'.last_category_selected',$row->category_id);
								break;
							}
						}
					}
					foreach($this->rows as $row){
						if($only_if_products && $row->number_of_products<1) continue;
						$link = hikashop_completeLink('category&task=listing&cid='.$row->category_id.'&name='.$row->alias.$this->menu_id);
						$class = '';
						if($found == $row->category_id){
								$class=' current active';
						}
						?>
						<li class="hikashop_category_list_item<?php echo $class; ?>" <?php echo $width; ?>>
							<a href="<?php echo $link; ?>" >
							<?php
								echo $row->category_name;
								if($this->params->get('number_of_products',0)){
									echo ' ('.$row->number_of_products.')';
								}
							 ?>
							</a>
						</li>
						<?php
					}
				?>
				</ul>
		<?php
			}
			break;
		case 'allchildsexpand':
			?>
			<div id="category_panel_<?php echo $this->params->get('id');?>" class="pane-sliders">
			<?php
			if(!empty($this->rows)){
				foreach($this->rows as $k => $row){
					if($only_if_products && $row->number_of_products<1) continue;
					$link = hikashop_completeLink('category&task=listing&cid='.$row->category_id.'&name='.$row->alias.$this->menu_id);
					?>
					<div class="panel">
						<h3 class="jpane-toggler title" id="category_pane_<?php echo $k;?>" style="cursor:default;">
							<span>
								<a href="<?php echo $link;?>">
									<?php
										echo $row->category_name;
										if($this->params->get('number_of_products',0)){
											echo ' ('.$row->number_of_products.')';
										}
									?>
								</a>
							</span>
						</h3>
						<div class="jpane-slider content">
							<ul class="hikashop_category_list<?php echo $this->params->get('ul_class_name'); ?>"><?php
							if(!empty($row->childs)){
								$app =& JFactory::getApplication();
								$found='';
								if(JRequest::getString('option')==HIKASHOP_COMPONENT && in_array(JRequest::getString('ctrl','category'),array('category','product'))){
									$found = $app->getUserState(HIKASHOP_COMPONENT.'.last_category_selected');
									if(JRequest::getString('ctrl','category')=='product'&&JRequest::getString('task','listing')=='show'){
										$cid = JRequest::getInt('category_pathway',0);
									}else{
										$cid = JRequest::getInt('cid',0);
									}
									foreach($row->childs as $child){

										if($cid == $child->category_id){

											$found=$child->category_id;
											$app->setUserState(HIKASHOP_COMPONENT.'.last_category_selected',$child->category_id);
											break;
										}
									}
								}

								$limit = $this->params->get('child_limit');
								$i = 0;
								foreach($row->childs as $child){
									if($only_if_products && $child->number_of_products<1) continue;
									if(!empty($limit) && $i >= $limit){
										break;
									}
									$i++;
									$link = hikashop_completeLink('category&task=listing&cid='.$child->category_id.'&name='.$child->alias.$this->menu_id);
									$class = '';
									if($found==$child->category_id){
										$class=' current active';
									}
									?>
									<li class="hikashop_category_list_item<?php echo $class; ?>">
										<a href="<?php echo $link; ?>">
										<?php
											echo $child->category_name;
											if($this->params->get('number_of_products',0)){
												echo ' ('.$child->number_of_products.')';
											}
										?>
										</a>
									</li>
									<?php
								}
							}
							?></ul>
						</div>
					</div><?php
				}
			}
			?></div><?php
			break;
		case 'allchilds':
			jimport('joomla.html.pane');
			$found = -1;
			if(JRequest::getString('option')==HIKASHOP_COMPONENT && in_array(JRequest::getString('ctrl','category'),array('category','product')) && $cid = JRequest::getInt('cid',0)){
				if(JRequest::getString('ctrl','category')=='product'&&JRequest::getString('task','listing')=='show'){
					$cid = JRequest::getInt('category_pathway',0);
				}
				$i=0;
				if(!empty($this->rows)){
					foreach($this->rows as $k => $row){
						if($only_if_products && $row->number_of_products<1) continue;
						if($row->category_id==$cid){
							$found = $i;
							break;
						}
						if(!empty($row->childs)){
							foreach($row->childs as $child){
								if($child->category_id==$cid){
									$found = $i;
									break 2;
								}
							}
						}
						$i++;
					}
					$app = JFactory::getApplication();
					if($found>=0){
						$app->setUserState(HIKASHOP_COMPONENT.'.last_category_selected',$found);
					}else{
						$found = (int)$app->getUserState(HIKASHOP_COMPONENT.'.last_category_selected');
					}
				}

			}else{
				$cid = 0;
			}
			$this->tabs = hikashop_get('helper.sliders');
			$this->tabs->setOptions(array('startOffset'=>$found,'startTransition'=>0));
			echo $this->tabs->startPane( 'category_panel_'.$this->params->get('id'));
			if(!empty($this->rows)){
				foreach($this->rows as $k => $row){
					if($only_if_products && $row->number_of_products<1) continue;
					if($this->params->get('number_of_products',0)){
						$row->category_name.= ' ('.$row->number_of_products.')';
					}

					if( !$this->module || $this->params->get('links_on_main_categories')){
						$link = hikashop_completeLink('category&task=listing&cid='.$row->category_id.'&name='.$row->alias.$this->menu_id);
						$row->category_name = '<a href="'.$link.'">'.$row->category_name.'</a>';
					}
					echo $this->tabs->startPanel($row->category_name, 'category_pane_'.$k);
					if(!empty($row->childs)){
						?><ul class="hikashop_category_list<?php echo $this->params->get('ul_class_name'); ?>"><?php
							foreach($row->childs as $child){
								if($only_if_products && $child->number_of_products<1) continue;
								$class = '';
								if($cid==$child->category_id){
									$class=' current active';
								}
								$link = hikashop_completeLink('category&task=listing&cid='.$child->category_id.'&name='.$child->alias.$this->menu_id);
								?>
								<li class="hikashop_category_list_item<?php echo $class; ?>">
									<a class="hikashop_category_list_item_link" href="<?php echo $link; ?>">
									<?php
										echo $child->category_name;
										if($this->params->get('number_of_products',0)){
											echo ' ('.$child->number_of_products.')';
										}
									?>
									</a>
								</li>
								<?php
							}
						?></ul><?php
					}
					echo $this->tabs->endPanel();
					?><script type="text/javascript">
						if (window.addEventListener)     { window.addEventListener('load', changeClass, false);  }
						else {  window.attachEvent('onload', changeClass);  }
						function changeClass()    {
							document.getElementById('<?php echo 'category_pane_'.$k; ?>').className="title pane-toggler";
						}
					</script><?php
				}
			}
			echo $this->tabs->endPane();

			break;
	}
	?>
	</div>
	<?php if(in_array($pagination,array('bottom','both')) && $this->params->get('show_limit') && $this->pageInfo->elements->total > $this->pageInfo->limit->value){ $this->pagination->form = '_bottom'; ?>
	<form action="<?php echo hikashop_currentURL();?>" method="post" name="adminForm_<?php echo $this->params->get('main_div_name').$this->category_selected;?>_bottom">
		<div class="hikashop_subcategories_pagination hikashop_subcategories_pagination_bottom">
		<?php echo $this->pagination->getListFooter($this->params->get('limit')); ?>
		<span class="hikashop_results_counter"><?php echo $this->pagination->getResultsCounter(); ?></span>
		</div>
		<input type="hidden" name="filter_order_<?php echo $this->params->get('main_div_name').$this->category_selected;?>" value="<?php echo $this->pageInfo->filter->order->value; ?>" />
		<input type="hidden" name="filter_order_Dir_<?php echo $this->params->get('main_div_name').$this->category_selected;?>" value="<?php echo $this->pageInfo->filter->order->dir; ?>" />
		<?php echo JHTML::_( 'form.token' ); ?>
	</form>
	<?php }
} ?>

I will try to see how to open by default as soon as possible.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
12 years 6 months ago #80225

Thanks Xavier.

Regarding the codes, I inserted it but the category module is still not displaying properly. Can I send you the admin login (through contact us?) so you can make tests and adjustments directly?

I noticed in the category options, Hikashop already have an option called "Random items" (where a random category bounce up to top & open up). Maybe for future release we can have another option there that allows the active category to bounce up & open?

Last edit: 12 years 6 months ago by simon2012.

Please Log in or Create an account to join the conversation.

  • Posts: 83935
  • Thank you received: 13593
  • MODERATOR
12 years 6 months ago #80521

I think that you should try instead to simply change the line:
$this->tabs->setOptions(array('startOffset'=>$found,'startTransition'=>0));

to:
$this->tabs->setOptions(array('startTransition'=>0));

in that file.

And please make sure that you're editing it for your frontend template and not another one, otherwise, you won't see any change.

The following user(s) said Thank You: simon2012

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
12 years 6 months ago #80612

Hi Nicolas

Can you please have a look in my back-end administrator? (did you receive the login I sent via "contact us"?). I have tried both suggestions but still cannot get it to work.

Thanks

Last edit: 12 years 6 months ago by simon2012.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
12 years 6 months ago #80783

Hi

Is there any other solutions? I don't know if I can continue using Hikashop if this problem cannot be solved.

Please Log in or Create an account to join the conversation.

  • Posts: 83935
  • Thank you received: 13593
  • MODERATOR
12 years 6 months ago #81037

Hi,

I looked at the problem on your website regarding the fact that the proper category didn't expand but couldn't find why that could have happened since the selection of the category in PHP was the correct one.
And you said in your first message that having no category open would be fine too.
So, the code change I gave you was to do that.
I checked your website and that's what it is actually doing.
No category is opened when a page is displayed.
So my suggestion is ok, as far as I can see.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
12 years 6 months ago #81142

Thanks Nicolas, that code worked (the changes did not come in effect until the next day, cookies?).

The menu is satisfactory in it's current state but an expanding one (with correct category) would be best. Is this possible?

Last edit: 12 years 6 months ago by simon2012.

Please Log in or Create an account to join the conversation.

  • Posts: 83935
  • Thank you received: 13593
  • MODERATOR
12 years 6 months ago #81387

That's how it should be actually by default.
As I said in my last post, the data sent by HikaShop to the accordion library of joomla is correct on your website. I debugged that myself. So I don't see why it doesn't work on your website and don't have a solution for you.

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
12 years 5 months ago #81872

The problem is also present on my other domain.
http://shoptest.cloudaccess.net/cat-menu/category/18-sub-4.html

Please Log in or Create an account to join the conversation.

  • Posts: 26251
  • Thank you received: 4040
  • MODERATOR
12 years 5 months ago #82027

Hi,

I have fixed the problem in your website and I have made a fix in HikaShop which would be include in the next package.
If you want a generic fix, please edit the file administrator/com_hikashop/helpers/sliders.php
and replace

		if($this->mode == 'pane') {
			jimport('joomla.html.pane');
			$this->tabs = JPane::getInstance('sliders', $options);
			$ret .= $this->tabs->startPane($name);
		} elseif($this->mode == 'sliders') {
			$ret .= JHtml::_('sliders.start', $name, $options);
		} else {
By this:
		if($this->mode == 'pane') {
			jimport('joomla.html.pane');
			if(!empty($this->options))
				$options = array_merge($options, $this->options);
			$this->tabs = JPane::getInstance('sliders', $options);
			$ret .= $this->tabs->startPane($name);
		} elseif($this->mode == 'sliders') {
			if(!empty($this->options))
				$options = array_merge($options, $this->options);
			$ret .= JHtml::_('sliders.start', $name, $options);
		} else {
Regards and sorry for the inconvenient.


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: simon2012

Please Log in or Create an account to join the conversation.

  • Posts: 14
  • Thank you received: 0
12 years 5 months ago #82204

Thanks Jerome :)

Please Log in or Create an account to join the conversation.

Time to create page: 0.097 seconds
Powered by Kunena Forum