ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Right...almost there so please stick with me! :-)
This works BUT it isn't closing the div in the correct place. See code below and then look at http://www.online-printing-services....roducts_id=141
It should be closing just before Upload your artwork and appears to be there but not doing anything so obviously in the wrong place.
<?php
for($i=0;$i<sizeof($options_name);$i++) {
?>
<?php /* MY CODE STARTS HERE */ ?>
<?php if (stristr($options_name[$i],'Finishing Options')) { ?><div id="MYHIDDENATTRIBUTESDIV" style="background-color:#ffffcc;"><?php } ?>
<?php if (stristr($options_name[$i],'Upload your artwork')) { ?></div><?php } ?>
<?php /* MY CODE ENDS HERE */ ?>
<div id="<?php echo $options_wrapper_id[$i];//gjh42 ?>" class="wrapperAttribsOptions">
<?php
if ($options_comment[$i] != '' and $options_comment_position[$i] == '0') {
?>
<h3 class="attributesComments"><?php echo $options_comment[$i]; ?></h3>
<?php
}
?>
Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk
Seeing how it was attempted to be rewritten I thought I would also offer my own description of what was going on in hopes that in your future "programming" or rewriting that you might find a solution faster.
The fields array is used to retrieve data that has been obtained from running a query bsically. In this case, attributes.php created an array which is identified with the variable $options_names[] which is like saying, take this array and add an item to the end of the list. I donw what to assign it, so could you give it the next number in the list of arrays (ie, the position within the array associated with the number of items in the array.)
So, now in tpl_modules_attributes the array is available for use, but in review of attributes.php, the fields were not appended/included with the generated array, I also had placed too much trust in the code found to make this happen, thinking that we just needed to change the name of some of the items, not realizing that perhaps the solution was more of a thought experiment. Therefore when applied here in the template, there was perhaps more of a change needed than "expected".
So anyways, when comparing $options_names to fields, well that wouldn't "work" which is why you had to have != to get a result. Effectively what was being done was comparing the options array to an array called fields which didn't exist.
In the first "attempt", the entire string to be displayed (options variable) was. Being compared to a simple, single string. The variable had been assigned everything that was to appear between the h4 tag basically, not just a small part that we are looking for. To find the small part, a string inspection must be done. I still haven't looked up what the expected operation of stristr is, but will do that next if the above failed. My understanding of it's function again assuming that the original author of that code understood what they were doing is to search the string and if the small piece entered on the right side is somewhere inside the left side (the string) then to return true or at least a value that is not false.
Hopefully, if you have gotten it to work as expected, perhaps you could repost the functional code to help the next one do this. It's been difficult to give sound code from within a cell phone. My apologies for taking so many attempts to resolve this. The extra code snippet of the template certainly helped.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Hmm. Unfortunately and I don't know why, I can not view the code source for this page, so I can't comment on the sequencing. I did submit the page for markup validation and there is an incorrectly closed <ui> which may be part of the problem, or the javascript to make that all happen are a number of validation errors btw, but the others do not appear to prevent doing what you are trying to do.
Btw, I was kind of kidding about it being my last attempt. I should have caught that difference yesterday before providing the suggestion before. :)
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Thats ok. If you look here it appears to close it.
<div id="MYHIDDENATTRIBUTESDIV" style="background-color:#ffffcc;"><div id="wAttrib-14" class="wrapperAttribsOptions">
<h4 class="optionName back">Finishing Options</h4><div style="clear:both;" /></div><div class="back"><div id="productattributesheaderbg"></div><div id="productattributesmidbg">
<span style="font-size:12pt;">Would you like Optional Extras? Choose from the following finishing options or scroll down to add to cart.</span><br />
<br style="clear:both;" /></div><div id="productattributesfooterbg"></div></div>
<br class="clearBoth" />
<div id="wAttrib-27" class="wrapperAttribsOptions">
<h4 class="optionName back"><label class="attribsSelect" for="attrib-27">Perforations</label></h4><div style="clear:both;" /></div><div class="back"><div id="productattributesheaderbg"></div><div id="productattributesmidbg">
<select name="id[27]" id="attrib-27">
<option value="188">NONE</option>
<option value="135">1 ( £44.75 )</option>
<option value="136">2 ( £58.02 )</option>
<option value="137">3 ( £71.57 )</option>
</select>
<br style="clear:both;" /></div><div id="productattributesfooterbg"></div></div>
<br class="clearBoth" />
<div id="wAttrib-28" class="wrapperAttribsOptions">
<h4 class="optionName back"><label class="attribsSelect" for="attrib-28">Cuts</label></h4><div style="clear:both;" /></div><div class="back"><div id="productattributesheaderbg"></div><div id="productattributesmidbg">
<select name="id[28]" id="attrib-28">
<option value="189">NONE</option>
<option value="138">1 ( £20.70 )</option>
<option value="139">2 ( £20.70 )</option>
<option value="140">3 ( £20.70 )</option>
<option value="141">4 ( £20.70 )</option>
<option value="142">5 ( £20.70 )</option>
<option value="143">6 ( £20.70 )</option>
<option value="144">7 ( £20.70 )</option>
<option value="145">8 ( £20.70 )</option>
<option value="146">9 ( £20.70 )</option>
</select>
<br style="clear:both;" /></div><div id="productattributesfooterbg"></div></div>
<br class="clearBoth" />
<div id="wAttrib-30" class="wrapperAttribsOptions">
<h4 class="optionName back"><label class="attribsSelect" for="attrib-30">Round Cornering</label></h4><div style="clear:both;" /></div><div class="back"><div id="productattributesheaderbg"></div><div id="productattributesmidbg">
<select name="id[30]" id="attrib-30">
<option value="190">NONE</option>
<option value="151">1 x 3mm ( £40.92 )</option>
<option value="152">2 x 3mm ( £40.92 )</option>
<option value="153">3 x 3mm ( £40.92 )</option>
<option value="154">4 x 3mm ( £40.92 )</option>
<option value="181">1 x 10mm ( £40.92 )</option>
<option value="182">2 x 10mm ( £40.92 )</option>
<option value="183">3 x 10mm ( £40.92 )</option>
<option value="184">4 x 10mm ( £40.92 )</option>
</select>
<br style="clear:both;" /></div><div id="productattributesfooterbg"></div></div>
<br class="clearBoth" />
<div id="wAttrib-41" class="wrapperAttribsOptions">
<h4 class="optionName back"><label class="attribsSelect" for="attrib-41">Drilling</label></h4><div style="clear:both;" /></div><div class="back"><div id="productattributesheaderbg"></div><div id="productattributesmidbg">
<select name="id[41]" id="attrib-41">
<option value="191">NONE</option>
<option value="160">1 x 3mm ( £25.68 )</option>
<option value="161">2 x 3mm ( £25.68 )</option>
<option value="162">3 x 3mm ( £25.68 )</option>
<option value="163">4 x 3mm ( £25.68 )</option>
<option value="164">1 x 3.5mm ( £25.68 )</option>
<option value="165">2 x 3.5mm ( £25.68 )</option>
<option value="166">3 x 3.5mm ( £25.68 )</option>
<option value="167">4 x 3.5mm ( £25.68 )</option>
<option value="168">1 x 6mm ( £25.68 )</option>
<option value="169">2 x 6mm ( £25.68 )</option>
<option value="170">3 x 6mm ( £25.68 )</option>
<option value="171">4 x 6mm ( £25.68 )</option>
</select>
<br style="clear:both;" /></div><div id="productattributesfooterbg"></div></div>
<br class="clearBoth" />
<div id="wAttrib-26" class="wrapperAttribsOptions">
<h4 class="optionName back">Folds</h4><div style="clear:both;" /></div><div class="back"><div id="productattributesheaderbg"></div><div id="productattributesmidbg">
<input type="radio" name="id[26]" value="157" class="radio" id="attrib-26-157" /><label class="attribsRadioButton zero" for="attrib-26-157"><img src="images/attributes/fold-single.jpg" class="attributeimage" /> Single Fold ( £60.38 )</label><br style="clear:both;" />
<input type="radio" name="id[26]" value="158" class="radio" id="attrib-26-158" /><label class="attribsRadioButton zero" for="attrib-26-158"><img src="images/attributes/fold-roll.jpg" class="attributeimage" /> x 2 - Roll Fold ( £70.93 )</label><br style="clear:both;" />
<input type="radio" name="id[26]" value="172" class="radio" id="attrib-26-172" /><label class="attribsRadioButton zero" for="attrib-26-172"><img src="images/attributes/zfold.jpg" class="attributeimage" /> x 2 - Z Fold ( £70.93 )</label><br style="clear:both;" />
<input type="radio" name="id[26]" value="173" class="radio" id="attrib-26-173" /><label class="attribsRadioButton zero" for="attrib-26-173"><img src="images/attributes/cross-fold.png" class="attributeimage" /> x 2 - Cross Fold ( £70.93 )</label><br style="clear:both;" />
<input type="radio" name="id[26]" value="159" class="radio" id="attrib-26-159" /><label class="attribsRadioButton zero" for="attrib-26-159"><img src="images/attributes/fold-roll.jpg" class="attributeimage" /> x 3 - Roll Fold ( £81.47 )</label><br style="clear:both;" />
<input type="radio" name="id[26]" value="174" class="radio" id="attrib-26-174" /><label class="attribsRadioButton zero" for="attrib-26-174"><img src="images/attributes/zfold.jpg" class="attributeimage" /> x 3 - Z Fold ( £81.47 )</label><br style="clear:both;" />
<br style="clear:both;" /></div><div id="productattributesfooterbg"></div></div>
<br class="clearBoth" />
</div><div id="wAttrib-46" class="wrapperAttribsOptions">
<h4 class="optionName back"><label class="attribsUploads" for="attrib-46-0">Upload your artwork</label></h4><div style="clear:both;" /></div><div class="back"><div id="productattributesheaderbg"></div><div id="productattributesmidbg">
<input type="file" name="id[TEXT_PREFIX46]" id="attrib-46-0" /><br /><h2>Choose your artwork, click Add to Cart and wait for your file to upload.</h2>
<input type="hidden" name="UPLOAD_PREFIX1" value="46" />
<input type="hidden" name="TEXT_PREFIXUPLOAD_PREFIX1" />
<br style="clear:both;" /></div><div id="productattributesfooterbg"></div></div>
Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk
So, the problem I see which was reported by the validation, is that <div class="back"> that is in each attribute display is not closed, therefore, in the end of things there is no closure for the newly added div tag. I sure if that div should be <div class="back" /> or if it should have a </div> somewhere towards the end of a data set. Basically if you count the number of opening divs and subtract the number of closing divs where <div xxx /> equals zero plus and zero minus, then you end up with a positive number at the bottom/at completion of display of one attribute...
You would want to search your code for the above div statement, and if I remember correctly that was one thing pointed out in the forum as a correction/validation issue. It's been a while since I have looked at the thread that I am thinking about, and probably couldn't find it if I tried.![]()
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
Thats ok, I'll figure it out...well used to doing these things anyway. The important things is...IT WORKED!!! in the end.
So this was the final code:
In tpl_modules_attributes.php find <?php
for($i=0;$i<sizeof($options_name);$i++) {
?>
And just below paste:
<?php if (stristr($options_name[$i],'YOUR STARTING OPTION NAME GOES HERE')) { ?><div id="MYHIDDENATTRIBUTESDIV" style="background-color:#ffffcc;"><?php } ?>
<?php if (stristr($options_name[$i],'YOUR ENDING OPTION NAME GOES HERE')) { ?></div><?php } ?>
Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...
I've finally got around to resolving the ending div issue on this. Just stick the div in ul tags.
So this is the absolute final code:
Find:
In tpl_modules_attributes.php find <?php
for($i=0;$i<sizeof($options_name);$i++) {
?>
And just below paste:
<?php if (stristr($options_name[$i],'YOUR STARTING OPTION NAME GOES HERE')) { ?><ul class="optionalExtrasContainer"><div id="optionalExtras"><?php } ?>
<?php if (stristr($options_name[$i],'YOUR ENDING OPTION NAME GOES HERE')) { ?></div></ul><?php } ?>
Then in your stylesheet add (to get rid of margins and padding if required on the ul tags):
ul.optionalExtrasContainer {
margin:0px;
padding:0px;
}
You could repeat this code and make several attribute groups too.
I may make this into some sort of mod at some point soon and upload it.
Nick Smith - Venture Design and Print
https://venturedesignandprint.co.uk
It may already be your plan, but may I suggest that if/when you create that plugin, you consider making the groupings an admin configurable option.
When doing so, have a format like
Start1:end1,start2:end2, etc
Then use a series of explode with accompanying trim to remove leading and following spaces. Perhaps a different seperator to account for. Typical characters in said attributes.
ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...