News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

add a class tag to auto-generated customfields

Started by remeedella, March 17, 2013, 01:29:40 AM

Previous topic - Next topic

remeedella

Hey all,

I might need someone with a little programming experience that I don't have to help me out.
I have some custom fields assigned to products and I was wondering about the way they are displayed in the product details page. My issue is I am building something out of bootstrap and everything is going swimmingly so far in converting to fluid. The only thing standing in my way right now is those darned input fields. They do not adjust to page fluidly, but I can make them!

It looks something like this for the custom fields.<span class="product-field-display"><select name="customPrice[1][18]" id="customPrice118">. The <select name="" id=""> is always auto generated and what I need to do is add a class to all of those input fields, I want to add let's say a class="span9" to the actual <select> reference. It won't work to add it with the span class="product-field-display" it needs to be added directly to the drop down input field thats a child of the span tag. I've tested it and I don't really want to look for any other workarounds or methods so my question is, I know which file or the main one where this all works but I don't know how to select just that <select> tag and add a class="span9" to it always when there is one. Can anyone help me with some coding to tie that in? As far as I know this is the file where it is referenced and needs some code added. default_customfields.php


I'll paste it:

<div class="product-fields">
       <?php
       $custom_title = null;
       foreach ($this->product->customfieldsSorted[$this->position] as $field) {
          if ( $field->is_hidden ) //OSP http://forum.virtuemart.net/index.php?topic=99320.0
             continue;
         if ($field->display) {
       ?><div class="product-field product-field-type-<?php echo $field->field_type ?>">
          <?php if ($field->custom_title != $custom_title) { ?>
             <span class="product-fields-title" ><?php echo JText::_($field->custom_title); ?></span>
             <?php
             if ($field->custom_tip)
            echo JHTML::tooltip($field->custom_tip, JText::_($field->custom_title), 'tooltip.png');
         }
         ?>
              <span class="product-field-display"><?php echo $field->display ?></span>
              <span class="product-field-desc"><?php echo jText::_($field->custom_field_desc) ?></span>
          </div>
          <?php
          $custom_title = $field->custom_title;
         }
       }
       ?>


Cookies will be rewarded

PRO



thats the wrong file

cart variants custom fields are done in

default_addtocart.php

You can do this a couple ways
Here is 1
str_replace

switch this
<?php echo $field->display; ?>

for this

<?php $field->display = str_replace( '"<select', '"<select class="class" ', $field->display ); ?><?php echo $field->display; ?>


please test, cause I havent

remeedella


PRO



<?php
$document = JFactory::getDocument();
$document->addScriptDeclaration("
   jQuery(document).ready(function($) {
    $('select').addClass('class-name');
   });
");
?>

remeedella

where do I place this!? Right before <?php echo $field->display; ?>    ???

PRO

that code can be placed anywhere

as long as its not inside any <?php tags

You can place it close to the top in

views/productdetails/tmpl/default.php

remeedella

I added it literally before anything on that page and you're right! This works, you're a god amongst men.

You can now see the fluid in action when you shrink http://www.newreleasewall.com/primetimegourmet/index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=2&virtuemart_category_id=3

Thankssss

PRO


remeedella

What do you mean? It is working, "span9" class is added to the select fields

PRO

picture attached

[attachment cleanup by admin]

remeedella

My bad dude! I just realized, I think I overwrote it because I forgot to do a template override. If you're online now can you re-check? Should be dandy!

PRO


remeedella

of course I know firebug, why would I not know firebug