Help Center
When using the Ptengine page editing feature, it is crucial to understand each function and its associated impacts.
This article introduces recommended ways of using commonly used operations such as "editing HTML," "copying and pasting elements," "moving elements," and “editing styles" in Ptengine.
With the page editing feature, you can edit the HTML of a page and apply it to live via Ptengine. While this feature is very convenient, improper use may lead to side effects.
Interactive content refers to content that functions based on user interactions such as clicks or mouse overs. This includes menus, accordions, add-to-cart buttons, purchase buttons, forms, links, etc.
1)Editing HTML may affect JavaScript events that act on specific elements, potentially rendering the original functionality unusable. For instance, editing a slider may cause it to stop sliding properly. Similarly, popups or accordions that open on click may be affected. 2) Editing HTML may disrupt the original structure of modules, rendering functions unusable or causing layout abnormalities. This includes interactions like tabs or menus not responding correctly to mouse clicks.
1)Minimize changes to interactive elements
If you need to modify related elements, you'll need to reapply events using JavaScript after editing and apply them similarly in the "code mode" for a similar experience.
2)Perform edits at individual levels
When modifying multiple contents, it's recommended to edit each one individually rather than selecting a higher-level hierarchy to edit the HTML. This will reduce the risk of breaking the original page structure.
For example, if you want to modify the three contents within the red frame in the image below, there are two methods: Method 1 Recommended: Make individual changes to 1, 2, and 3, completing the fixes in three edits. Method 2 Not Recommended: By selecting the higher-level layer containing 1, 2, and 3, you can edit the HTML of the lower layer as well. While this allows for multiple changes at once, it makes the structure more prone to breaking. Method 2 allows for quicker changes but increases the likelihood of breaking the page structure, leading to adverse effects on interactive elements.
You can copy any element on the page and paste it elsewhere.
While this feature offers great flexibility, improper use may lead to unexpected consequences. Here are some common scenarios and considerations:
If the copied element contains an ID, pasting it may result in multiple elements with the same ID on the page. According to W3C standards, IDs should be unique, and having duplicates can cause unexpected effects.
Events based on IDs may not trigger, leading to the copied elements not behaving interactively as expected.
After pasting, check the HTML of the pasted element to ensure there are no ID conflicts. If conflicts exist, modify the corresponding ID strings to avoid duplicates on the page.
function findDuplicateIds() { const allElements = document.querySelectorAll('*'); const idMap = {}; allElements.forEach((element) => { const id = element.id; if (id) { if (idMap[id]) { console.log(`Duplicate ID elements exist on the page: ${id}`); } else { idMap[id] = true; } } }); } findDuplicateIds();
This code helps identify duplicate IDs on the page. Here's how to use it:
Pasting elements to a different location on the page may result in the pasted element not retaining its structure or styles compared to the original element.
For instance, on an e-commerce site, pasting product information (including images, prices, and basic details) to a different location might disrupt the layout of the entire product page.
Check CSS selectors and adjust the style to the pasted elements using “edit style” in the tool bar. Use inline styles on HTML or reduce the hierarchy of CSS selector specifications to prevent style disruptions caused by copying and pasting operations.
After pasting, interactive function from the original element may not work on the pasted element. For example, if a "Add to Cart" button is copied and the add to cart function may not work for the pasted button.
Events bound to the original element (such as adding items to cart or checkout) usually do not automatically work on the newly pasted element.
Avoid copying highly interactive elements. If necessary, use JavaScript to add events to the newly pasted elements. When adding events, you can use a code mode like the one shown below to execute JavaScript logic.
Moving elements is a common need. For example, if analysis from Ptengine's heatmaps reveals that information like discounts or full guarantees pushes purchases, but such details are buried lower on the page, moving them to prominent positions might be beneficial.
Currently, content movement can be achieved through “copy original elements, paste it to the new position, and delete the original element”. Thus, moving requires considering the effects of copying and pasting mentioned before.
Minimize moving highly interactive elements. If necessary, adjust JavaScript to ensure events are triggered on the newly moved elements. Use the Ptengine code mode and utilize the element movement API shown below:
// targetSelector: ptKit.moveElement( "targetSelector", "relativeSelector", 'before', { timeout: 60000, interval: 500 } );
Element styles can be adjusted within the page editing feature. This includes changes to colors, layouts, fonts, etc.
1)Situation Description: If style changes are not applied after adjustment, it's typically due to style conflicts, where the new styles have lower priority. 2)Recommended Usage: If changes don't take effect, directly modify styles using CSS code mode and use !important to increase the priority of styles.
Understanding the principles and potential impacts of each feature allows for more effective and safe use of Ptengine's page editing feature. By avoiding common issues like those mentioned above, you can ensure normal website operation and provide an excellent user experience. Always remember to back up and preview before making any changes.
Was this article helpful?
Thanks for your feedback.
Sorry about that. Do you mind sharing how we can improve?
Write your feedback here...
We have received your feedback and will make sure to improve this article. We will get in touch with you once we do.