Community Forums

how to position options?

Template support & advice for OpenCart v1.x

how to position options?

Postby burley » Tue Jul 24, 2012 8:31 pm

I have a online swimwear shop and some products have multiple options (4+) for the top and the bottom of a specific bikini.

I would like to be able to position them next to each other, instead of under each other or even group them )for instance for the top and bottom). I´ve looked and searched, and have found countless ways to change the position of the modules, but it seems theres no way to reposition the options if you have multiple.

Can anybody help me out?
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby MarketInSG » Wed Jul 25, 2012 12:46 am

you will need to style your css with float. A little complicating.
User avatar
MarketInSG
 
Posts: 2596
Joined: Wed Nov 16, 2011 3:53 am
Location: Singapore

Re: how to position options?

Postby burley » Wed Jul 25, 2012 4:40 am

Complicating how?

I have quite a lot experience changing/modding code (php/CSS), just no idea how to write it from scratch
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby MarketInSG » Wed Jul 25, 2012 5:51 am

you will need to assign them style="float:left". That will make them be able to float beside each other.
User avatar
MarketInSG
 
Posts: 2596
Joined: Wed Nov 16, 2011 3:53 am
Location: Singapore

Re: how to position options?

Postby burley » Wed Jul 25, 2012 8:38 am

Ok, I understand, but how do I select which modules are left and which will be right?

Is there a way to do this with the code? If, for example, the option ID is below a certain number then sort it to the left if bigger then a number then it go's right.

I understand if statements and all, I can even modifhy them, but just can't write them :)
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby MarketInSG » Wed Jul 25, 2012 8:54 am

Code: Select all
<?php if ($option['name'] == 'something') { ?>
<div style="float:right">contents of options</div><?php } else { ?>
<div style="float:left">contents of options to float on right </div> <?php } ?>


you will have to try to figure it out according to your option names (i'm assuming they have different names so there will be sorted by their names).
User avatar
MarketInSG
 
Posts: 2596
Joined: Wed Nov 16, 2011 3:53 am
Location: Singapore

Re: how to position options?

Postby burley » Wed Jul 25, 2012 9:23 am

Thanks! I will give that a try tonight!

let you know how it works out!
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby burley » Wed Jul 25, 2012 1:11 pm

ok, got it working a bit, but not even close to my liking.

Also I'm having some issue's with the if statements. The options belonging to my products are all dropdown lists. And if i use the If statement as stated above, i'm getting a blank screen and and an error stating there is a unexpected } on line 385. Which is at the end of the copied/inserted code. I've added the code from product.tpl in a text file, it was a bit much to post in the thread.

But isn't there a more efficient way to use the error code? Using a variable which replaces the first part of the div container?

Something like;
Code: Select all

$div_container_1 = "<div style="float:right">";
$div_container_2 = "<div style="float:left">";

<?php if ($option['name'] == 'something') { ?>
$div_container_1
<?php } else { ?>
$div_container2


Again, no idea what I'm talking about, maybe it's just rubbish, and I have no idea how to make such a string work correctly. But perhaps it could work :)
Attachments
options-aligning.txt
(16.3 KiB) Downloaded 35 times
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby MarketInSG » Wed Jul 25, 2012 2:00 pm

you get an error because you didn't close your brackets. and you need to echo or print the var, not just place it there. it won't do anything if you just place it there. read php.net for more help
User avatar
MarketInSG
 
Posts: 2596
Joined: Wed Nov 16, 2011 3:53 am
Location: Singapore

Re: how to position options?

Postby burley » Wed Jul 25, 2012 2:02 pm

I'm sorry, it's not my intention at all to have you do all the work :)

Will place an update tonight
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby burley » Wed Jul 25, 2012 4:45 pm

Got it working! :D

Thanks for your support!

Two more question though;

If I want to declare more options to be sorted on the left/right, how do I add those additional option names to the code?
Withouth having to copy and adding the code for each option.

I've looked at php.net and read the manual, but couldn't find it.

Code: Select all
<!-- EXTRA REGEL - OPTIE LAYOUT -->
<?php if ($option['name'] == 'size') { ?>

       <!-- EXTRA REGEL - OPTIE LAYOUT -->
        <div style="float:right" id="option-<?php echo $option['product_option_id']; ?>" class="option">
       
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
           <!-- VOEG JE IMAGE HIER IN -->
         
          <select name="option[<?php echo $option['product_option_id']; ?>]">
            <option value=""><?php echo $text_select; ?></option>
            <?php foreach ($option['option_value'] as $option_value) { ?>
            <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
            <?php if ($option_value['price']) { ?>
            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
            <?php } ?>
            </option>
            <?php } ?>
          </select>
        </div>
       
<?php } else { ?>
        <div style="float:left" id="option-<?php echo $option['product_option_id']; ?>" class="option">
       
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
           <!-- VOEG JE IMAGE HIER IN -->
         
          <select name="option[<?php echo $option['product_option_id']; ?>]">
            <option value=""><?php echo $text_select; ?></option>
            <?php foreach ($option['option_value'] as $option_value) { ?>
            <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
            <?php if ($option_value['price']) { ?>
            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
            <?php } ?>
            </option>
            <?php } ?>
          </select>
        </div> <?php } ?>
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby MarketInSG » Thu Jul 26, 2012 8:24 am

base on your codes you gave below, add in a little more

this is what you have
Code: Select all
<?php if ($option['name'] == 'size') { ?>


this is what i change to
Code: Select all
<?php if ($option['name'] == 'size' || $option['name'] == 'something' || $option['name'] == 'more things') { ?>
User avatar
MarketInSG
 
Posts: 2596
Joined: Wed Nov 16, 2011 3:53 am
Location: Singapore

Re: how to position options?

Postby burley » Thu Jul 26, 2012 11:05 am

It works, but it places the additional options right next to the first one, which obviously looks like crap, so I guess it's back to copying the code for each option seperately. Simply got no clue how to due it otherwise.

Edit: tried copying the code and inserting it below the first option but I get an error again (unexpected send command)

what am I missing?

Code: Select all
   <?php foreach ($options as $option) { ?>

       
        <?php if ($option['type'] == 'select' )  { ?>

      <!-- EXTRA REGEL - OPTIE LAYOUT -->
<?php if ($option['name'] == 'size' ) { ?>

       <!-- EXTRA REGEL - OPTIE LAYOUT -->
        <div style="float:right; padding-right:50px" id="option-<?php echo $option['product_option_id']; ?>" class="option">
       
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
           <!-- VOEG JE IMAGE HIER IN -->
         
          <select name="option[<?php echo $option['product_option_id']; ?>]">
            <option value=""><?php echo $text_select; ?></option>
            <?php foreach ($option['option_value'] as $option_value) { ?>
            <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
            <?php if ($option_value['price']) { ?>
            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
            <?php } ?>
            </option>
            <?php } ?>
          </select>
        </div>
       
<?php } else { ?>

      <!-- EXTRA REGEL - OPTIE LAYOUT -->
<?php if ($option['name'] == 'model' ) { ?>

       <!-- EXTRA REGEL - OPTIE LAYOUT -->
        <div style="float:right; padding-right:50px" id="option-<?php echo $option['product_option_id']; ?>" class="option">
       
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
           <!-- VOEG JE IMAGE HIER IN -->
         
          <select name="option[<?php echo $option['product_option_id']; ?>]">
            <option value=""><?php echo $text_select; ?></option>
            <?php foreach ($option['option_value'] as $option_value) { ?>
            <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
            <?php if ($option_value['price']) { ?>
            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
            <?php } ?>
            </option>
            <?php } ?>
          </select>
        </div>
       
<?php } else { ?>

        <div style="float" id="option-<?php echo $option['product_option_id']; ?>" class="option">
       
          <?php if ($option['required']) { ?>
          <span class="required">*</span>
          <?php } ?>
          <b><?php echo $option['name']; ?>:</b><br />
           <!-- VOEG JE IMAGE HIER IN -->
         
          <select name="option[<?php echo $option['product_option_id']; ?>]">
            <option value=""><?php echo $text_select; ?></option>
            <?php foreach ($option['option_value'] as $option_value) { ?>
            <option value="<?php echo $option_value['product_option_value_id']; ?>"><?php echo $option_value['name']; ?>
            <?php if ($option_value['price']) { ?>
            (<?php echo $option_value['price_prefix']; ?><?php echo $option_value['price']; ?>)
            <?php } ?>
            </option>
            <?php } ?>
          </select>

        </div>                  <br /> <?php } ?>
       
       

        <?php } ?>
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby MarketInSG » Thu Jul 26, 2012 11:54 am

missing a semi colon somewhere, enjoy finding >:D Anyway, you can do so with a div clear at end of each option, that will ensure they appear below each other :)
User avatar
MarketInSG
 
Posts: 2596
Joined: Wed Nov 16, 2011 3:53 am
Location: Singapore

Re: how to position options?

Postby burley » Sun Jul 29, 2012 10:09 pm

Thanks again!
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am

Re: how to position options?

Postby burley » Mon Aug 20, 2012 11:32 am

Got it working as I want, it's not live jet, but will be soon.

I'm selling bikini's with several options for both the bottoms as the top. For example bikini A has 3 different tops, a customer needs (is required) to select at least one of them. But with the current setup I can only set every option as required or non at all, is there a way to change this?

Or will this be a huge amount of work?
burley
 
Posts: 330
Joined: Sun Oct 09, 2011 7:30 am


Return to Template Support

Who is online

Users browsing this forum: alpa2009 and 28 guests

Hosted by Arvixe Web Hosting