-- Bienvenue sur ce scripte d'example LUA -- Vous pouvez modifier ce scripte pour tester vos fonctionnalités -- Pour plus d'information sur LUA, vous pouvez consulter la documentation officiel : https://www.lua.org/docs.html -- local js = require "js" -- LuaJS (to access JS objects) local window = js.global -- Global object (window) local document = window.document -- Document object (DOM) local cms = window.cms -- CMS object (CraftYourCMS Helpers) -- Register your plugin (name (the plugin slug)) local plugin = cms:registerPlugin("custom-modal") -- Need to be the same as the created plugin name, else it not work -- Add a new module that can be rendered on the website -- (name, title) local modalModule = plugin:addModule("modal-module", "Boite de dialogue") -- Add setting editable by the admin for this module -- (name, type[options...], label, defaultValue) modalModule:addSetting("title", "text[required|minlength:3]", "Titre", "") modalModule:addSetting("body", "text[required|minlength:5]", "Contenu", "") -- Define the render function for this module -- The plugin will be automatically rendered on the website where the module is added by the admin modalModule:onRender(function(module) -- "module" is the current module object with all the properties / functions available -- Settings are automatically fetched for this specific module, depending where the admin are added it on a page and has configured it local title = module:getSetting("title") local body = module:getSetting('body') local modal = cms.modal:create("hello-world") modal:setTitle(title) modal:setBody(body) modal:setFooter("") modal:open() -- After your logic, return the string to render return nil end) --[[function setCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + (value || "") + expires + "; path=/"; } function getCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { document.cookie = name +'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; }--]]