<% // ================================================================= // Final, Corrected, and Stable Code by Gemini // This entire block goes into the "Content" field of the "Create a page" node. // IMPORTANT: You MUST enable Expression mode for this field. // ================================================================= // --- 1. GATHER DATA --- // Get data from the nodes that ran before this one. const webhookData = $('Webhook').first().json.body; const mainDataNode = $('Code in JavaScript (Lookup in sheet)'); // Use a shorter name const mainData = mainDataNode.exists ? mainDataNode.first().json : {}; const couponData = $('HTTP Request (coupon)'); const coupon = couponData.exists ? couponData.first().json.code.toString().trim() : ''; // --- 2. APPLY LOGIC --- // Determine which phases the user selected in the form. const addPhase1 = webhookData.add_phase_1 === 'true' || webhookData.add_phase_1 === true; const addPhase2 = webhookData.add_phase_2 === 'true' || webhookData.add_phase_2 === true; const addPhase3 = webhookData.add_phase_3 === 'true' || webhookData.add_phase_3 === true; const selectedBooks = []; const final_product_ids = []; const allPhases = mainData.final_output.study_plan; // Helper function to add books and IDs from a specific phase if selected. function addPhaseBooks(phaseData) { if (phaseData) { for (const key in phaseData) { if (phaseData[key].productId && phaseData[key].title && phaseData[key].image_url) { selectedBooks.push(phaseData[key]); final_product_ids.push(phaseData[key].productId); } } } } // Add books from each phase only if the user checked the box. if (addPhase1) addPhaseBooks(allPhases.phase_1); if (addPhase2) addPhaseBooks(allPhases.phase_2); if (addPhase3) addPhaseBooks(allPhases.phase_3); // Create the final string of product IDs for the purchase URLs. const final_ids_string = final_product_ids.join(','); // --- 3. RENDER THE HTML PAGE --- // Now, we start writing the HTML. We can use <%= %> to print our variables.
%>

سیر مطالعاتی اختصاصی <%= mainData.formalName %>

💡 تحلیل هوشمند

<%= mainData.final_output.analysis %>


<%= allPhases.phase_1.book_3.title %>


<%= allPhases.phase_1.book_4.title %>