Create - Random Products Module for Joomla

  • Posts: 39
  • Thank you received: 0
13 years 6 months ago #15536

Hello,

I want to create a module showing up 9 random product images in a table.
3 trs and 3 tds.

I've tried to solve it with javascript included into a mod.php file:

<html>
<head>
<title>JSProd</title>

<style type="text/css">

<!--

.table_jsprod {-moz-border-radius: 10px; margin: 20px;}
.table_td_jsprod {border: 1px solid grey;}

-->

</style>

<script language="javascript" >

<!--

// here will be the script





-->


</script>
</head>

<body> 

<table width="300" height="390" border="1" class="table_jsprod">
<tr>
   <td class="table_td_jsprod"> RANDOM IMAGE /></td>

   <td class="table_td_jsprod">RANDOM IMAGE</td>
   <td class="table_td_jsprod">RANDOM IMAGE</td>
</tr>

<tr>
   <td class="table_td_jsprod"> RANDOM IMAGE </td>
   <td class="table_td_jsprod"> RANDOM IMAGE </td>
   <td class="table_td_jsprod"> RANDOM IMAGE </td>
   
</tr>

<tr>
   <td class="table_td_jsprod"> RANDOM IMAGE </td>
   <td class="table_td_jsprod"> RANDOM IMAGE </td>
   <td class="table_td_jsprod"> RANDOM IMAGE </td>
   
</tr>

</table>
 
</body>

Now I have to write a script which shows random product images in each td. When you click on the image, you should be linked to the belonging product page of the product image.
How can I realize this? And which source can I use?

Regards,

Storm

Last edit: 13 years 6 months ago by Storm15.

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
13 years 6 months ago #15543

You can look ad the code of the function listing of the file components/com_hikashop/views/product/view.html.php where there is some code to load randomly a defined number of products with their information, including their main image. But why not just use the content module we provide in HikaShop which can already list products randomly ?

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

  • Posts: 39
  • Thank you received: 0
13 years 6 months ago #15546

I want to give it a special style. The module's classes are the same like the hikashop product listing.
When I change hikashop_container, the style of the product listing will be changed, too.
Another reason is that I wanted to struggle with javascript (learning by doing) :)
If there's a way to seperate the style of the content module and the style of the product listing, I'd prefer the content modul anyway.
(I hope you can understand my english)

Regards,

Storm

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
13 years 6 months ago #15547

You should go in the menu Display->Views and edit the file listing_div of the view product in order to edit the code of the products listing.
There, you can easily set apart the module display and the component display with that code:

if(JRequest::getVar('hikashop_front_end_main',0)){
echo 'in module';
}else{
echo 'in component';
}

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

  • Posts: 39
  • Thank you received: 0
13 years 6 months ago #15551

In which line do I have to put the code?

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

  • Posts: 82867
  • Thank you received: 13373
  • MODERATOR
13 years 6 months ago #15562

It depends what you want to do...
You need to make sure that the code is inside php tags: <?php code ?>

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

Time to create page: 0.051 seconds
Powered by Kunena Forum