Page 1 of 3 123 LastLast
Results 1 to 10 of 30
  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    red flag Wrap DIV around attributes

    Hi there, I'm looking for a way to wrap a DIV around several attributes as I want to create a button that will open and close a div with extra options inside it on my product page. Normally the DIV would be hidden until someone clicks a button. There will be attributes outside the closed DIV and also inside the closed DIV.

    So you would have something like this:

    Print Options (FIRST SET OF ATTRIBUTE OPTIONS):
    Full Colour Single Sided
    Full colour black & white reverse
    Full colour both sides

    <a href="OPENDIVBUTTON">Open</a>
    <div id="MYHIDDENATTRIBUTESDIV">Finishing Options: Option 1, Option 2, Option 3</div>

    Upload (LAST ATTRIBUTE OPTION)

    I came across some code which says it targets an attribute name but I am unsure how to use it. This would enable me to start a div before an attribute name and end it where I wanted.

    This is the code:

    <?php if (stristr($attributes_values->fields['products_options_name'],'MYFIRSTATTRIBUTENAME')) { ?><div id="MYHIDDENATTRIBUTESDIV"><?php } ?>

    <?php if (stristr($attributes_values->fields['products_options_name'],'MYLASTATTRIBUTENAME')) { ?></div><?php } ?>
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  2. #2
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Wrap DIV around attributes

    Quote Originally Posted by Nick1973 View Post
    Hi there, I'm looking for a way to wrap a DIV around several attributes as I want to create a button that will open and close a div with extra options inside it on my product page. Normally the DIV would be hidden until someone clicks a button. There will be attributes outside the closed DIV and also inside the closed DIV.

    So you would have something like this:

    Print Options (FIRST SET OF ATTRIBUTE OPTIONS):
    Full Colour Single Sided
    Full colour black & white reverse
    Full colour both sides

    <a href="OPENDIVBUTTON">Open</a>
    <div id="MYHIDDENATTRIBUTESDIV">Finishing Options: Option 1, Option 2, Option 3</div>

    Upload (LAST ATTRIBUTE OPTION)

    I came across some code which says it targets an attribute name but I am unsure how to use it. This would enable me to start a div before an attribute name and end it where I wanted.

    This is the code:

    <?php if (stristr($attributes_values->fields['products_options_name'],'MYFIRSTATTRIBUTENAME')) { ?><div id="MYHIDDENATTRIBUTESDIV"><?php } ?>

    <?php if (stristr($attributes_values->fields['products_options_name'],'MYLASTATTRIBUTENAME')) { ?></div><?php } ?>
    Slightly a different tact to this, but there is already a way to reference attributes without wrapping them in an additional div tag. It would require a sort of "consistency" to be considered across the implementation, but...

    So let's assume that an attribute to be controlled is designated as option name 1, option value 127, then the following css would hide the button and the label associated with it. If this could be worked into your javascript, you would simply need to identify for the button to do the toggling, what attribute options to control at the specific detail necessary to get the end result. This seems like the "same" level of work that would be necessary to wrap the attributes to begin with. Add to that, if the desire is to hide all values of option name 1, I would think there is a way to consider all items matching the criteria of #attrib-1-

    Code:
    #attrib-1-127, #attrib-1-127+label { display: none; }
    To address the break after the attribute, would add another item in the comma separated list with +br at the end (I think.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Wrap DIV around attributes

    But, now that I have reread your code snippet, I think that would go into your attributes.php file that would get inur override directory such as includes/modules/YOUR_TEMPLATE/ folder.

    The right side of the strstr statement that is in all caps, would be the text that indicates the last option and would be placed after the last option is displayed for the last option line, and before the first option is displayed for the first line.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Wrap DIV around attributes

    Do have to realize, that if you use the method you have described that the sequence of adding attributes to a product is crucial as if the last one is displayed first and the first displayed last, then the sequence will be out of order and the "feature" may not work as desired. :/
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    red flag Re: Wrap DIV around attributes

    Quote Originally Posted by mc12345678 View Post
    But, now that I have reread your code snippet, I think that would go into your attributes.php file that would get inur override directory such as includes/modules/YOUR_TEMPLATE/ folder.

    The right side of the strstr statement that is in all caps, would be the text that indicates the last option and would be placed after the last option is displayed for the last option line, and before the first option is displayed for the first line.
    Yeah I tried that but nothing happened...however I could have been doing it wrong which is why I am seeking help.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  6. #6
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Wrap DIV around attributes

    So, looking at an attributes.php file that was included with a different module (and I believe it is 1.5.1), towards the end of the file, almost like 5 lines from the end, you should see something like:

    Code:
                    // attributes images table
                    $options_attributes_image[] = trim($tmp_attributes_image) . "\n";
                    $products_options_names->MoveNext();
                  }
    I would consider adding the custom code as such to just before the $options_attributes_image[] line:

    Code:
    if (stristr($attributes_values->fields['products_options_name'],'MYFIRSTATTRIBUTENAME')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = '<div id="MYHIDDENATTRIBUTESDIV">' . $options_name[$last_id];
    } elseif (stristr($attributes_values->fields['products_options_name'],'MYLASTATTRIBUTENAME')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = $options_name[$last_id] . '</div>';
    }
    This may work...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  7. #7
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Wrap DIV around attributes

    On second thought, I might change the previous a little... Notice the change of the second if...


    So, looking at an attributes.php file that was included with a different module (and I believe it is 1.5.1), towards the end of the file, almost like 5 lines from the end, you should see something like:

    Code:
                    // attributes images table
                    $options_attributes_image[] = trim($tmp_attributes_image) . "\n";
                    $products_options_names->MoveNext();
                  }
    I would consider adding the custom code as such to just before the $options_attributes_image[] line:

    Code:
    if (stristr($attributes_values->fields['products_options_name'],'MYFIRSTATTRIBUTENAME')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = '<div id="MYHIDDENATTRIBUTESDIV">' . $options_name[$last_id];
    } 
    
    if (stristr($attributes_values->fields['products_options_name'],'MYLASTATTRIBUTENAME')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = $options_name[$last_id] . '</div>';
    }
    This may work... Also, the change was made, in the event for some reason the first attribute is the last attribute. Otherwise, the div would never be closed when it had the elseif statement... (Sorry)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #8
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    red flag Re: Wrap DIV around attributes

    Quote Originally Posted by mc12345678 View Post
    On second thought, I might change the previous a little... Notice the change of the second if...


    So, looking at an attributes.php file that was included with a different module (and I believe it is 1.5.1), towards the end of the file, almost like 5 lines from the end, you should see something like:

    Code:
                    // attributes images table
                    $options_attributes_image[] = trim($tmp_attributes_image) . "\n";
                    $products_options_names->MoveNext();
                  }
    I would consider adding the custom code as such to just before the $options_attributes_image[] line:

    Code:
    if (stristr($attributes_values->fields['products_options_name'],'MYFIRSTATTRIBUTENAME')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = '<div id="MYHIDDENATTRIBUTESDIV">' . $options_name[$last_id];
    } 
    
    if (stristr($attributes_values->fields['products_options_name'],'MYLASTATTRIBUTENAME')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = $options_name[$last_id] . '</div>';
    }
    This may work... Also, the change was made, in the event for some reason the first attribute is the last attribute. Otherwise, the div would never be closed when it had the elseif statement... (Sorry)
    Ok will try this and see if this solves my issue. I will get back to you.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  9. #9
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Wrap DIV around attributes

    Quote Originally Posted by Nick1973 View Post
    Ok will try this and see if this solves my issue. I will get back to you.
    I've I tried this in modules/MYTEMPLATENAME/attributes.php

    // grouped attributes wrapper //
    if (stristr($attributes_values->fields['products_options_name'],'Finishing Options')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = '<div id="MYHIDDENATTRIBUTESDIV" style="background-color:#ffffcc;">' . $options_name[$last_id];
    }

    if (stristr($attributes_values->fields['products_options_name'],'Upload your artwork')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = $options_name[$last_id] . '</div>';
    }

    // attributes images table
    $options_attributes_image[] = trim($tmp_attributes_image) . "\n";
    $products_options_names->MoveNext();
    }
    // manage filename uploads
    $_GET['number_of_uploads'] = $number_of_uploads;
    // zen_draw_hidden_field('number_of_uploads', $_GET['number_of_uploads']);
    zen_draw_hidden_field('number_of_uploads', $number_of_uploads);
    }


    This doesn't do anything.

    If you go here it might be easier for you to see what I am trying to achieve.

    http://www.online-printing-services....&products_id=1

    I need the div to start at Finishing Options and end just before Upload your artwork.

    So where you see Folds, for different products this might be something else before Upload your artwork.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  10. #10
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Wrap DIV around attributes

    Quote Originally Posted by Nick1973 View Post
    I've I tried this in modules/MYTEMPLATENAME/attributes.php

    // grouped attributes wrapper //
    if (stristr($attributes_values->fields['products_options_name'],'Finishing Options')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = '<div id="MYHIDDENATTRIBUTESDIV" style="background-color:#ffffcc;">' . $options_name[$last_id];
    }

    if (stristr($attributes_values->fields['products_options_name'],'Upload your artwork')) {
    end($options_name);
    $last_id=key($options_name);
    $options_name[$last_id] = $options_name[$last_id] . '</div>';
    }

    // attributes images table
    $options_attributes_image[] = trim($tmp_attributes_image) . "\n";
    $products_options_names->MoveNext();
    }
    // manage filename uploads
    $_GET['number_of_uploads'] = $number_of_uploads;
    // zen_draw_hidden_field('number_of_uploads', $_GET['number_of_uploads']);
    zen_draw_hidden_field('number_of_uploads', $number_of_uploads);
    }


    This doesn't do anything.

    If you go here it might be easier for you to see what I am trying to achieve.

    http://www.online-printing-services....&products_id=1

    I need the div to start at Finishing Options and end just before Upload your artwork.

    So where you see Folds, for different products this might be something else before Upload your artwork.

    Yeah, on retrospect that won't do anything, the variable $attributes_values doesn't exist in this scope. Need to change $attributes_values to $products_options_names

    :)
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 
Page 1 of 3 123 LastLast

Similar Threads

  1. Making text wrap around all images
    By robbin21973 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 8 Feb 2011, 10:55 PM
  2. wrap text around categories image
    By Edm in forum General Questions
    Replies: 0
    Last Post: 3 Jun 2008, 01:07 PM
  3. Wrap price in DIV
    By Nimbuz in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 10 Nov 2007, 07:20 PM
  4. Column Layout Grid, need to wrap <div> around <img>
    By duntuk in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 11 Apr 2007, 06:10 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg