Community Forums

Need module output in table format

Coding & concept discussion for OpenCart v1.x development

Need module output in table format

Postby dharam81 » Mon Apr 30, 2012 12:35 pm

Hi to all,
i am new to opencart but it feel me good while using opencart. its great open source platform.
i am trying to use latest post module to give out put in tabular format like

model1 model2 model3 model4
model5 model6 model7 model8
model9 model10 model11 model12
.........................

with model number to display only no other information need to display.

any help wud be appricated.

Dharam
dharam81
 
Posts: 40
Joined: Mon Apr 30, 2012 12:26 pm

Re: Need module output in table format

Postby pprmkr » Mon Apr 30, 2012 2:29 pm

The controller catalog/controller/module/latest.php does not use the field 'model'.
You need to modify the controller.
At line 50 starts:
Code: Select all
         $this->data['products'][] = array(
            'product_id' => $result['product_id'],
            'thumb'       => $image,
            'name'        => $result['name'],
            'price'       => $price,
            'special'     => $special,
            'rating'     => $rating,
            'reviews'    => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
            'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id']),
         );

Change into:
Code: Select all
         $this->data['products'][] = array(
            'product_id' => $result['product_id'],
            'model'       => $result['model'],
            'thumb'       => $image,
            'name'        => $result['name'],
            'price'       => $price,
            'special'     => $special,
            'rating'     => $rating,
            'reviews'    => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
            'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id']),
         );


The template catalog/view/theme/default/template/module/latest.tpl can be adjusted to display only the model with link.
Open the templatefile and replace:
Code: Select all
      <?php foreach ($products as $product) { ?>
     <div>
        <?php if ($product['thumb']) { ?>
        <div class="image"><a href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a></div>
        <?php } ?>
        <div class="name"><a href="<?php echo $product['href']; ?>"><?php echo $product['name']; ?></a></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 } ?>
        </div>
        <?php } ?>
        <?php if ($product['rating']) { ?>
        <div class="rating"><img src="catalog/view/theme/default/image/stars-<?php echo $product['rating']; ?>.png" alt="<?php echo $product['reviews']; ?>" /></div>
        <?php } ?>
        <div class="cart"><input type="button" value="<?php echo $button_cart; ?>" onclick="addToCart('<?php echo $product['product_id']; ?>');" class="button" /></div>
      </div>
      <?php } ?>

with:
Code: Select all
      <?php foreach ($products as $product) { ?>
         <div style="width: 23%; float: left; padding: 2px;">
            <a href="<?php echo $product['href']; ?>"><?php echo $product['model']; ?></a>
         </div>
      <?php } ?>


In this form it shows 4 colums ( each 23% ).
latest_model.jpg
latest_model.jpg (10.31 KiB) Viewed 2170 times
User avatar
pprmkr
 
Posts: 753
Joined: Sat Jan 08, 2011 3:05 pm

Re: Need module output in table format

Postby dharam81 » Tue May 01, 2012 11:28 am

Hi pprmkr,

i made the required changed but not getting output display correctly.

below is screenshot for my website home page.

any help appreciated.

Cheers
Attachments
chek here.JPG
home page after changes
chek here.JPG (11.32 KiB) Viewed 2147 times
dharam81
 
Posts: 40
Joined: Mon Apr 30, 2012 12:26 pm

Re: Need module output in table format

Postby dharam81 » Tue May 01, 2012 12:57 pm

Hi pprmkr,

i managed to get list.
but i am using same code for two module and its getting messed up at home page.
below is home page attached.
can u tell me reason for this?
Code: Select all
<div class="box">
   <div class="box-heading">Latest Released Exams</div>
  <div class="box-content">
    <div class="box-product">
         <?php foreach ($products as $product) { ?>
         <div style="width: 10%; float: left; padding: 1px;">
            <a href="<?php echo $product['href']; ?>"><?php echo $product['model']; ?></a>
         </div>
       <?php } ?>     
    </div>
  </div>
</div>


module 2

Code: Select all
<div class="box">
   <div class="box-heading">Latest Updated Exams</div>
  <div class="box-content">
    <div class="box-product">
         <?php foreach ($products as $product) { ?>
         <div style="width: 10%; float: left; padding: 1px;">
            <a href="<?php echo $product['href']; ?>"><?php echo $product['model']; ?></a>
         </div>
       <?php } ?>     
    </div>
  </div>
</div>



Attachments
messed up.JPG
messed up.JPG (98.4 KiB) Viewed 2137 times
dharam81
 
Posts: 40
Joined: Mon Apr 30, 2012 12:26 pm

Re: Need module output in table format

Postby pprmkr » Tue May 01, 2012 2:09 pm

The div's are higher than the available space.

Make more space by adding:

Code: Select all
<br style="clear: both;" />


just after:
Code: Select all
 <?php } ?>
User avatar
pprmkr
 
Posts: 753
Joined: Sat Jan 08, 2011 3:05 pm

Re: Need module output in table format

Postby dharam81 » Tue May 01, 2012 5:02 pm

worked like charm.

salute to pprmkr.

one more question.

where to change colour to content to black?
dharam81
 
Posts: 40
Joined: Mon Apr 30, 2012 12:26 pm

Re: Need module output in table format

Postby pprmkr » Tue May 01, 2012 5:11 pm

dharam81 wrote:where to change colour to content to black?


Fisrt you have to know:
- version of OpenCart ?
- the theme you use ?
- black background for all content, container or boxes only ?

When you post an url to your site, I can guide you ...
User avatar
pprmkr
 
Posts: 753
Joined: Sat Jan 08, 2011 3:05 pm

Re: Need module output in table format

Postby dharam81 » Tue May 01, 2012 5:35 pm

guide4pass.com (not live still in develment)

in last discussion we got out put in table in want to change table content in black instead of green.Also if i can have green border for tabular out put.

i m using latest version of opncart 1.5.2

i am using custom theme.
dharam81
 
Posts: 40
Joined: Mon Apr 30, 2012 12:26 pm

Re: Need module output in table format

Postby pprmkr » Tue May 01, 2012 7:25 pm

To change the background of the box-content:

Try following steps.

Open catalog/view/theme/flanacart/stylesheet/stylesheet.css
At line 741:
Code: Select all
.box .box-content {
   padding: 0px;
}


Change into:
Code: Select all
.box .box-content {
   background: #000000;
   border: 1px solid #81C93A;
   padding: 5px;
}
User avatar
pprmkr
 
Posts: 753
Joined: Sat Jan 08, 2011 3:05 pm

Re: Need module output in table format

Postby dharam81 » Tue May 01, 2012 8:34 pm

Hello Sir,

i changed to style sheet as per given details but it didnt work.

any help?

Regards
dharam81
 
Posts: 40
Joined: Mon Apr 30, 2012 12:26 pm

Re: Need module output in table format

Postby pprmkr » Wed May 02, 2012 5:30 am

Please refresh ( F5 ), then the changes in the stylesheet will take effect.
User avatar
pprmkr
 
Posts: 753
Joined: Sat Jan 08, 2011 3:05 pm

Re: Need module output in table format

Postby dharam81 » Wed May 02, 2012 2:11 pm

thanks pprmkr.
but actually i didnt mean that output.
i want to make change colour for my content to black and want to let heading remain green.

have a look on green font colour in attachement i want to change this colour.

thanka in advance.


dk
Attachments
attached.JPG
attached.JPG (49.14 KiB) Viewed 2094 times
dharam81
 
Posts: 40
Joined: Mon Apr 30, 2012 12:26 pm

Re: Need module output in table format

Postby pprmkr » Wed May 02, 2012 3:26 pm

Sorry for the misunderstanding.

In that case you should change the color of the links.

In the stylesheet on line 36:
Code: Select all
a, a:visited, a b {
   color: #81C93A;
   text-decoration: underline;
   cursor: pointer;
}

Change into:
Code: Select all
a, a:visited, a b {
   color: #000000;
   text-decoration: underline;
   cursor: pointer;
}


Also add the color of the link in the welcome message on line 307 :
Code: Select all
#header #welcome a {
    text-decoration: none;
}

Change into:
Code: Select all
#header #welcome a {
    color: #81C93A;
    text-decoration: none;
}
User avatar
pprmkr
 
Posts: 753
Joined: Sat Jan 08, 2011 3:05 pm

Re: Need module output in table format

Postby dharam81 » Wed May 02, 2012 4:49 pm

thanks pprmkr.

solved now.
once more request.
how to change background to white for the attached image.



regards
Attachments
mostview.png
mostview.png (11.92 KiB) Viewed 2087 times
dharam81
 
Posts: 40
Joined: Mon Apr 30, 2012 12:26 pm

Re: Need module output in table format

Postby pprmkr » Thu May 03, 2012 7:00 am

To change the background of the box_content left and right, open the stylesheet and at line 745:
Code: Select all
#column-left .box .box-content, #column-right .box .box-content {
    padding: 5px;
}

Change into:
Code: Select all
#column-left .box .box-content, #column-right .box .box-content {
    background: #ffffff;
    padding: 5px;
}
User avatar
pprmkr
 
Posts: 753
Joined: Sat Jan 08, 2011 3:05 pm

Re: Need module output in table format

Postby tulip_craft » Wed Dec 05, 2012 11:03 am

hi, can anybody help me.??
I also want to modify the latest.tpl, delete "wishlist" and "compare" button..
but now i'm facing a problem, latest product module won't show image of the product itself..

latest.php
Code: Select all
$this->data['products'][] = array(
            'product_id' => $result['product_id'],
            'thumb'       => $image,
            'name'        => $result['name'],
            'description' => mb_substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
            'price'       => $price,
            'special'     => $special,
            'rating'     => $rating,
            'reviews'    => sprintf($this->language->get('text_reviews'), (int)$result['reviews']),
            'href'        => $this->url->link('product/product', 'product_id=' . $result['product_id']),


latest.tpl
Code: Select all
<?php foreach ($products as $product) { ?>
      <div class="prod_hold">
        <?php if ($product['thumb']) { ?>
        <a class="wrap_link" href="<?php echo $product['href']; ?>"><img src="<?php echo $products['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a>


i've tried to add ['product_id'], but still it can't show the image product..
Code: Select all
<?php foreach ($products as $product) { ?>
      <div class="prod_hold">
        <?php if ($product['thumb']) { ?>
        <a class="wrap_link" href="<?php echo $products['product_id']['href']; ?>"><img src="<?php echo $products['product_id']['thumb']; ?>" alt="<?php echo $product['name']; ?>" /></a>
        <?php } ?>


page source:
<h2 class="heading-title"><span>Latest</span></h2>
<div class="box-content">
<div class="box-product fixed">
<div class="prod_hold">
<a class="wrap_link" href="http://tulip-craft.com/index.php?route=product/product&amp;product_id=70"><img src="<b>Notice</b>: Undefined index: thumb in <b>/home/k0238696/public_html/catalog/view/theme/tulipcraft/template/module/latest.tpl</b> on line <b>15</b>" alt="KP 02" /></a>
<div class="pricetag_small"><span class="price">Rp10,000,-</span></div>
<div class="info">
<h3>KP 02</h3>
<p>


how to fix this.??
All about Crochet and Knitting, a Handicraft Store -> http://tulip-craft.com
User avatar
tulip_craft
 
Posts: 85
Joined: Tue Dec 04, 2012 9:54 am

Re: Need module output in table format

Postby pprmkr » Wed Dec 05, 2012 7:57 pm

In the template it's not:
Code: Select all
<?php echo $products['thumb']; ?>


It's the loop foreach products as product, so change into
Code: Select all
<?php echo $product['thumb']; ?>
User avatar
pprmkr
 
Posts: 753
Joined: Sat Jan 08, 2011 3:05 pm

Re: Need module output in table format

Postby tulip_craft » Fri Dec 07, 2012 9:02 pm

solved.. thanks anyway.!!

Code: Select all
  <a class="wrap_link" href="<?php echo $product['href']; ?>"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" />


change to:
Code: Select all
Code: Select all
 <a class="wrap_link" href="<?php echo $product['href']; ?>"><span class="image"><img src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" />
All about Crochet and Knitting, a Handicraft Store -> http://tulip-craft.com
User avatar
tulip_craft
 
Posts: 85
Joined: Tue Dec 04, 2012 9:54 am


Return to Concepts

Who is online

Users browsing this forum: No registered users and 10 guests

Hosted by Arvixe Web Hosting