Post by whitespace » Mon Apr 28, 2008 12:30 pm

Hello people!

We're trying out opencart and have a design which requires the currency box to be place inside the
product area, and not in the header.

We've tried moving

Code: Select all

<?php if (isset($currency)) { ?>
    <?php echo $currency; ?>
    <?php } ?>
into the product.tpl, but this does not seem to work.

Anyone have any ideas?

Thanks!
K

Newbie

Posts

Joined
Mon Apr 28, 2008 12:28 pm

Post by bruce » Mon Apr 28, 2008 1:01 pm

Currency is a module and the data is gathered in catalog\extension\module\currency.php
and displayed using catalog\template\default\module\currency.tpl

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by whitespace » Mon Apr 28, 2008 1:37 pm

Thanks bruce,
How does one make the currency module load in product.tpl?

Cheers!
K

Newbie

Posts

Joined
Mon Apr 28, 2008 12:28 pm

Post by bruce » Mon Apr 28, 2008 3:03 pm

The following loads all (installed + enabled) modules.

Code: Select all

		$template->set($module->fetch());
in catalog\controller\home.php

The files I listed in the previous post combine with

Code: Select all

    <?php if (isset($currency)) { ?>

    <?php echo $currency; ?>

    <?php } ?>
in catalog\template\default\layout.tpl to produce the result you see normally.

I could help you better if you posted a screen shot of, say, an html mockup of what you are trying to achieve.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by whitespace » Mon Apr 28, 2008 3:25 pm

Hmm, well, I looked at product.php, and it seems to be loading all the modules:

Code: Select all

$view->set('images', $image_data);
$template->set($module->fetch()); 
$template->set('content', $view->fetch('content/product.tpl'));	  
$response->set($template->fetch('layout.tpl'));
But when you try to echo the $currency in product.tpl, it is undefined. Does that mean it's not loading the module at all? It seems to only work on layout.tpl.

This is what we are trying to achieve:-

http://www.whitespace.hk/ss.jpg[/img]

Thanks!
K

Newbie

Posts

Joined
Mon Apr 28, 2008 12:28 pm

Post by bruce » Mon Apr 28, 2008 7:40 pm

Here is enough to add a currency dropdown into the product area. I leave the positioning, styling and the language icon (also a module) to you. You will have to remove the currency dropdown on the header from catalog\template\default\layout.tpl or changing the currency will not work.

For your reference, I based the new code on the last 4 lines of catalog\controller\home.php and most of catalog\extension\module\currency.php

You might also like to have a look at this too http://forum.opencart.com/index.php/top ... ml#msg4997

Make the following changes to catalog\template\default\content\product.tpl are (with extra code shown for placement)...
Note also that the main form tag had to move below the currency stuff so that we do not end up with embedded forms.

Code: Select all

<link rel="stylesheet" type="text/css" href="catalog/template/default/css/product.css">
<script type="text/javascript" src="catalog/javascript/ajax/jquery.js"></script>
<script type="text/javascript" src="catalog/javascript/thickbox/thickbox-compressed.js"></script>
<link rel="stylesheet" type="text/css" href="catalog/javascript/thickbox/thickbox.css" />
  <div class="heading">
       <?php if ($price) { ?>
	  <div class="right"><?php echo $price; ?></div>
       <?php } ?>    
  	<div class="left"><?php echo $heading_title; ?></div>
  </div>
  <br class="brclear" />
  <br />
  <!--  testing new location for Currency  -->
    <?php if (isset($currency)) { ?>
    <?php echo $currency; ?>
    <?php } ?>  
  <!--  testing new location for Currency  -->  
<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data">
  <div id="product">

add the following to catalog\controller\product.php (extra code shown for positioning)

Code: Select all

      		foreach ($results as $result) {
        		$image_data[] = array(
          			'title' => $result['title'],
          			'popup' => $image->href($result['filename']),
          			'thumb' => $image->resize($result['filename'], $config->get('config_image_width'), $config->get('config_image_height')),
        		);
      		}

            /*
            *   Start of show currency module in product.tpl 
            */
            $language->load('extension/module/currency.php');
            $c = $this->locator->create('template');
            $c->set('options', $option_data);
            $c->set('heading_title', $language->get('heading_title'));
            $c->set('action', $url->href('home'));
            $c->set('text_currency', $language->get('text_currency'));
            $c->set('entry_currency', $language->get('entry_currency'));
            $c->set('default', $currency->getCode());
            $c->set('currencies', $database->cache('currency', "select * from currency order by title"));
            $view->set('currency', $c->fetch('module/currency.tpl'));
            /*
            *   End of show currency module in product.tpl
            */
      		$view->set('images', $image_data);
	  
	  		$template->set($module->fetch());

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm
Who is online

Users browsing this forum: No registered users and 2 guests