Im making my template for VM, and im modifying almost all the available views, so occasionally i find some bugs. Sometimes there are not even bugs, just incomplete migrations of code from earlier versions, or just missing fragments of code.
Hope someone take a look to this and make appropriate corrections.
RECOMMEND VIEW
The mail_confirmed.php generates a close modal box button, if it is a facebox, but not if it is a fancybox. Checking on ask a question view, the mail_confirmed.php has a small script that generates the appropriate close button, checking if facebox or fancybox is enabled.
SOLUTION: copy the script from ASK A QUESTION to RECOMMEND view.
PRODUCTDETAILS VIEW
Generating the PDF/PRINT/EMAIL link icons:
The icons are generated with this code:
if (VmConfig::get('pdf_icon', 1) == '1') {
echo $this->linkIcon($link . '&format=pdf', 'COM_VIRTUEMART_PDF', 'pdf_button', 'pdf_button_enable', false);
}
echo $this->linkIcon($link . '&print=1', 'COM_VIRTUEMART_PRINT', 'printButton', 'show_printicon');
echo $this->linkIcon($MailLink, 'COM_VIRTUEMART_EMAIL', 'emailButton', 'show_emailfriend', false);
As you can see, for the PDF icon, it checks with VmConfig what the configuration is, and if its true generates the icon. But for print and email it does not check that.
Digging here ive found that function "linkIcon" already check the configuration setting before generating the icon, so it looks like the VmConfig::get for PDF link is redundant here.
SOLUTION: i didnt try, but looks like removing the IF block should still check for the config setting before generating the icon.
PRODUCTDETAILS VIEW
Recommend email is shown in a modal box DIFFERENT from others that cant be closed from a link or button.
When user recommend and gets redirected to the mail_confirmed.php a close button is generated with an "onclick" attribute that close the facebox or fancybox (supposing that the first bug ive commented is already solved). This close button CAN NOT CLOSE the modal box.
SOLUTION: Its quite difficult to explain. I think that most important is to have a consistent modal function that works the same for all links.
In my case, i noticed that "ask a question" button generated a modal that was same looking than "recommend", but with different generated html, and different calling to the modal window.
Ask a question use this code on top of default.php (on productdetails view)
$document->addScriptDeclaration("
//<![CDATA[
jQuery(document).ready(function($) {
$('a.ask-a-question').click( function(){
".$box."
return false ;
});
/* $('.additional-images a').mouseover(function() {
var himg = this.href ;
var extension=himg.substring(himg.lastIndexOf('.')+1);
if (extension =='png' || extension =='jpg' || extension =='gif') {
$('.main-image img').attr('src',himg );
}
console.log(extension)
});*/
});
//]]>
");
Its a script that catch the click on the link and generates the modal. And when reaching the mail_confirmed.php of askquestion view, the close button WORKS.
So ive added a catch click on recommend link to generate the modal like the ask a question, and removed the inline modal generator (class="modal" rel="{handler: 'iframe', size: {x: 700, y: 550}}")
NOTE: print icon generates the same modal than recommend, but in this case, no CLOSE button is generated on the iframe output, so i didnt modify this. But i still think that all modal should be generated the same way, reducing coding, and using less resources on server and client side.
PRODUCTS OUT OF STOCK
When selected configuration "products out of stock can be ordered, and Availability field is shown".
I use "COM_VIRTUEMART_ON_REQUEST" value for this field, and a language override to replace this string on each language i use (english and spanish).
This works ok for normal products, but for products with child products, stockable variants or custom fields, the text is not translated, and instead the "COM_VIRTUEMART_ON_REQUEST" string is shown.
I realize that in fact, this text IS TRANSLATED on server side, but then some script on client side is modifying this text according to the variant or custom field selected, and changing back to "COM_VIRTUEMART_ON_REQUEST" again.
SOLUTION: It may be possible to modify the script to retrieve the translated value of the string instead of the string it self? Adding JTEXT wouldnt fix this?
OTHER THOUGHTS
Some parts of the code are away from modification as they are part of the VM core, but i think it should be kept on the VIEW side. Im referring to "linkIcon" (to generate PDF/Print/Email icons) or the way stockable variant product generates the select boxes. Both keep away the class attribute, and add inline style to to objects. Even adding an IMPOSSIBLE TO REACH ID, like "customPrice03". This makes almost impossible to style with CSS.
Maybe adding classes to the objects, and not adding inline style would help.
This is just what ive found today. Im almost finishing with styling of my views, and ive found many other things like the ones described above, but didnt realize to write them down, so now are lost... Any other i found i will post.
Regards!