Using different comments module

  • Posts: 127
  • Thank you received: 6
11 years 8 months ago #136669

-- url of the page with the problem -- : www.juicybike.info/index.php?option=com_...tric-bike&Itemid=234
-- HikaShop version -- : 2.2.1
-- Joomla version -- : 3.1.5
-- PHP version -- : 5.4.14

Hi
Firstly, though I think Hikashop is brilliant and I've noticed the support you have offered us before has been excellent I would like to use a different product-comments (reviews, testimonials) system on our site.

The system Freestyle Support offers for its "Testimonials" allows a category of product to be used. We have several versions of our Sport bike, for instance, with reviews (comments, testimonials etc) built up over several generations of that product, over several years from our old site. So I think by creating a module in Freestyle I can list only the reviews for, say, our Classic range of bikes and present those with each of the Classic style bike in our range.

My problem is that I can not seem to place the module in the code.

I've attached the file to this message (show_tabular.php) and you can see the results on the site. The code is at line 290 or so.

My background is in asp and the change to php is daunting! I'm too old now to get excited by a new language (i know php isn't new, just new to me!). Any help would be very gratefully received!!

Here's the snippet of code that I'm working on...

<div class="hikashop_tabs_content" id="hikashop_show_tabular_comment">
        <?php
  			jimport('joomla.application.module.helper');
			$modules = JModuleHelper::getModules( 'mod_Testimonials_Classic_Range' );
			echo '<pre>';
			foreach($modules as $module)
				{
					echo JModuleHelper::renderModule($module);
				}
            echo 'working here...**************************************************************';
			echo '</pre>';
        ?>
        <div id="hikashop_product_vote_listing" class="hikashop_product_vote_listing">
          
            
          
          <?php
            echo $layout_vote_listing;
          ?>
        </div>

Hope it's something simple and not too embarrassing for me - really, any help appreciated!!
Kind regards
Bob Wales

Attachments:

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

  • Posts: 84237
  • Thank you received: 13681
  • MODERATOR
11 years 8 months ago #136756

Your code is good. The issue is that you added it inside the if for the display of the whole vote tabs of HikaShop. That means that if you deactivated the votes of HikaShop, your code is not run either. So you should put your div/li outsite that if:
if($status_vote == "comment" || $status_vote == "two" || $status_vote == "both" ){

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

  • Posts: 127
  • Thank you received: 6
11 years 8 months ago #136982

Well, firstly, thanks for looking at this - much appreciated.
I did turn on the voting and comments options and this didn't change the views.
Did you spot the "Working here ****************" annotation in the code, which leads me to conclude that section of the code is firing (because it does show on the interpreted page), but not displaying the module.
Does that make sense?
Kind regards
Bob

Last edit: 11 years 8 months ago by Bobwales.

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

  • Posts: 127
  • Thank you received: 6
11 years 8 months ago #137002

Also, when I use print_r for the module I'm trying to display I get the following output:

stdClass Object
(
[id] => 0
[title] =>
[module] => mod_Testimonials_Classic_Range
[position] =>
[content] =>
[showtitle] => 0
[control] =>
[params] =>
[style] => none
)

Does this help make sense?

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

  • Posts: 84237
  • Thank you received: 13681
  • MODERATOR
11 years 8 months ago #137105

Mmm. I checked the page but I can see the testimonial module in the "Reviews" tab of your product.

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

  • Posts: 127
  • Thank you received: 6
11 years 8 months ago #137344

You must have seen the page as I attempted various tests. Right now my code is working, displaying the wrong comments.
I think the problem lays with extracting the current product category id. I am using $this->element->category_id but this doesn't pick up the correct category_id for the Classic bike range (which should be 19, but is showing as 12). The other bikes, Sport and Urban, are fine.

The code implemented at the site ( www.juicybike.info ) at the moment is:

<?php
$ordering = 0;
switch($this->element->category_id)
{
case 19:
$ordering = 1; /* ordering 1 is Classic Range Testimonials */
break;
case 18:
$ordering = 2; /* ordering 2 is Sport Range Testimonials */
break;
case 12:
$ordering = 3; /* ordering 3 is Urban Compact Range Testimonials */
break;
}

if($ordering) // if this product is one of the 3 categories for which freestyle testimonials are available...
{
echo ' fss testimonials are available, selected from ordering column, which for this product is ';
echo (int)$ordering;

$db = JFactory::GetDBO();
$db->setQuery("SELECT * FROM JB_fss_prod WHERE ordering = " . (int)$ordering);

$product = $db->loadObject();
$fss_product_id = $product->id;

$params = new JRegistry();
$params->set('prodid', $fss_product_id);
$params->set('dispcount', 4);
$params->set('listtype', 1);
$params->set('maxlength', 5000);
$params->set('show_more', 1);
$params->set('show_add', 1);
$params->set('maxheight', 0);
$params->set('speed', 0);

$lang = JFactory::getLanguage();
$lang->load("mod_fss_test");

require(JPATH_SITE."/modules/mod_fss_test/mod_fss_test.php");
}
else // display the standard Hikashop comments
{
echo '<div id="hikashop_product_vote_listing" class="hikashop_product_vote_listing">';
echo $layout_vote_listing;
echo '</div>';
}
?>

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

  • Posts: 84237
  • Thank you received: 13681
  • MODERATOR
11 years 8 months ago #137354

That's not how you should get the category id on the product page.
The categories of the current product are available as an array in the variable $this->categories

The following user(s) said Thank You: Bobwales

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

  • Posts: 127
  • Thank you received: 6
11 years 8 months ago #137361

Thanks Nicolas! Is there any document describing this?

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

  • Posts: 127
  • Thank you received: 6
11 years 8 months ago #137365

Ok - seen it at the top of the page!
So, $this->categories returns an array of the current product categories...
How do I use that in the code above?

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

  • Posts: 84237
  • Thank you received: 13681
  • MODERATOR
11 years 8 months ago #137377

It depends. You probably want to get all the category_ids with a loop on that array and then change your query you have a different condition in order to display the comments of all the categories of the product.

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

  • Posts: 127
  • Thank you received: 6
11 years 8 months ago #137392

We are only using 2 category groups: Parent is "Electric Bikes" (id=12) and then 3 categories (of electric bike) with id values of 19, 20 or 21.
Is there no way to get to the sub category directly for a product?

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

  • Posts: 127
  • Thank you received: 6
11 years 8 months ago #137451

Panic over! Got there with your help, for which I am very grateful.
Tried a new tack...
For anyone who might be interested, here's the code now:

<?php 
		
		$fssreview_found = 0;	
		$product_title = "default";
		if (strpos($this->element->product_name,'Classic') !== false) 
			{
			$fssreview_found = 1;
			$product_title = "Classic";
			} 
		elseif (strpos($this->element->product_name,'Sport') !== false) 
			{
			$fssreview_found = 2;
			$product_title = "Sport";
			} 
		elseif (strpos($this->element->product_name,'Compact') !== false) 
			{
			$fssreview_found = 3;
			$product_title = "Compact";
			}
		elseif (strpos($this->element->product_name,'Merlin') !== false) 
			{
			$fssreview_found = 2;
			$product_title = "Sport";
			}
		elseif (strpos($this->element->product_name,'Scooter') !== false) 
			{
			$fssreview_found = 2;
			$product_title = "Scooter";
			}
		
			
		if($fssreview_found) // if this product is one of the categories for which fss testimonials are available...
			{
						
			$db = JFactory::GetDBO();
			$db->setQuery("SELECT * FROM JB_fss_prod WHERE title LIKE " . "'%$product_title%'");
			$product = $db->loadObject();
			$fss_product_id = $product->id;
			
			$params = new JRegistry();
			$params->set('prodid', $fss_product_id);
			$params->set('dispcount', 4);
			$params->set('listtype', 1);
			$params->set('maxlength', 5000);
			$params->set('show_more', 1);
			$params->set('show_add', 0);
			$params->set('maxheight', 0);
			$params->set('speed', 0);

			$lang = JFactory::getLanguage();
			$lang->load("mod_fss_test");
			
			require(JPATH_SITE."/modules/mod_fss_test/mod_fss_test.php");
			}
		else // display the standard Hikashop comments 
			{
			echo '<div id="hikashop_product_vote_listing" class="hikashop_product_vote_listing">';
                  	echo $layout_vote_listing;
          		echo '</div>';
			}
	?>

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

Time to create page: 0.052 seconds
Powered by Kunena Forum