View Single Post
  #8  
Old 11-03-2011, 04:51 PM
Eugene Rimmer's Avatar
Eugene Rimmer Eugene Rimmer is offline
Senior Member
 
Join Date: Jan 2011
Location: Ecwid headquarters
Posts: 7,765
Default

1. You can modify the current page (and even the content generated by Ecwid to represent your store) inside the OnPageLoaded handler function. However, that takes a bit more that just calling document.write() - this construct creates some content that you pass to it via its parameter right there in the place where it was called. This method cannot be called in the event handlers (like the one I suggested to you), AJAX event handlers, timer and interval handlers and other functions of such type; it can only be called inside the plain script tags. Using document.write hence is not a way to modify pages in Ecwid.

The correct thing you need to use is a set of DOM manipulation methods, that allow you to create the HTML markup on the fly as a set of in-memory objects representing the tags and text you wish to use, and then add those nodes to the subtree of elements. This, however, is not an easy task, because DOM methods are somewhat difficult to comprehend and their implementation and availability differs between browsers. To overcome that, there are lots of handy JavaScript libraries, starting with uber-popular jQuery, where the topic of DOM manipulation is expressed with a concise set of cross-browser methods easy to comprehend, understand and use. You may consider using such library, but still it takes some time to learn the ways to work with it.

If you need a professional custom programming service, I can suggest to contact our colleagues at Qualiteam. They can create a custom script on your request of any complexity. Please, contact sales@qtmsoft.com if you are interested.

2. function(page.'PRODUCT') is a syntactically invalid construct in JavaScript language. Invalid constructs don't work.

The reference on correct using the 'function' keyword can be found here: https://developer.mozilla.org/en/Jav...ments/function . The 'function(page) {}' construct means 'lets create a unnamed subprogram, that accepts 1 parameter; lets consider referring to that parameter as "page" variable inside the body of our subprogram'. The 'page' comes into our function typically as an object, containing many different fields. One them is 'type' that represents the type of the page just opened, some of the other fields may appear only when a certain page type is opened. This is why if() constructs are needed - they aren't any bad, they just express the logic of your custom reaction to a certain opened page. You can build up the reaction on different types and other details of Ecwid pages according to your own needs.

Last edited by Eugene Rimmer; 11-04-2011 at 08:43 AM.