Regel 20: Regel 20:
 
valRetrieved = p.getdatafromslot( frompage, fromslot, fromtemplate, fromparam )
 
valRetrieved = p.getdatafromslot( frompage, fromslot, fromtemplate, fromparam )
 
-- label?
 
-- label?
 +
-- todo textareas
 
frame.args[value] = valRetrieved
 
frame.args[value] = valRetrieved
 
end
 
end
Regel 49: Regel 50:
 
p.getdatafromslot = function( page, slot, template, param )
 
p.getdatafromslot = function( page, slot, template, param )
 
local str = "Something went wrong"
 
local str = "Something went wrong"
 +
--
 
if ( template == "" ) then
 
if ( template == "" ) then
 
--todo
 
--todo
Regel 54: Regel 56:
 
return str
 
return str
 
end
 
end
 +
--
 
local slotdata = mw.slots.slotTemplates( slot, page )
 
local slotdata = mw.slots.slotTemplates( slot, page )
 
local str = slotdata[template][1][param]["_text"]
 
local str = slotdata[template][1][param]["_text"]

Versie van 22 sep 2023 00:10

Module:FF




invoke within form

{{#invoke:FF|input 
|type=text 
|name=myname
|value=Value here 
|id=fff-443434 
|class=form-control

|label=Name
|template=Data item

|slot=
|param=
|template=
}}


Getdata

Kikkers en tongzoenen - Sarah Mlynowski (2007), 1ᵉ druk, Uitgeverij Van Goor Unieboek BV, Houten:

Titel/-787178247

Works with parser function though


Titel/-787178247

getdatatest

Titel/-787178247


local p = {}

p.input = function(frame)
	local content = frame.args.content or frame.args[1] or ""
	local frompage = frame.args.page or ""
	local fromslot = frame.args.slot or ""
	local fromtemplate = frame.args.template or "" --template name
	local fromparam = frame.args.param or "" --template parameter
	local label = frame.args.label or ""
	-- slot
	-- Remove anything from args that should not be sent to FF
	local additkeys = { 'content', 'page', 'slot', 'template', 'param', 'label' }
	for k in ipairs( additkeys ) do
		if ( frame.args[k] ~= nil ) then
			frame.args[k] = nil
		end
	end
	--
	if ( frompage == not "" ) then
		valRetrieved = p.getdatafromslot( frompage, fromslot, fromtemplate, fromparam )
		-- label?
		-- todo textareas
		frame.args[value] = valRetrieved
	end
	
	-- FF
	local str = frame:extensionTag( '_input', content, frame.args )
	return str
end

--[[
test
]]--
p.getdata = function(frame)
	-- todo without pagename, get current page
	local page = frame.args.page or mw.title.getCurrentTitle()
	local slot = frame.args.slot or "main"
	local template = frame.args.template or ""  --template name
	local param = frame.args.param or nil  --template parameter
	-- getdatafromslot( page, slot, param )
	local str = p.getdatafromslot( page, slot, template, param )
	return str
	--local pagepropsparams = { slot, page, '@' .. slot }
	--local slotdatapf = frame:callParserFunction( '#slottemplates', pagepropsparams )
	--local slotdata = frame:preprocess( slotdatapf )
end

--[[
]]--
p.getdatafromslot = function( page, slot, template, param )
	local str = "Something went wrong"
	--
	if ( template == "" ) then
		--todo
		local str = mw.slots.slotContent( slot, page )
		return str
	end
	-- 
	local slotdata = mw.slots.slotTemplates( slot, page )
	local str = slotdata[template][1][param]["_text"]
	--local str = slotdata["Book"][1]["TitelNr"]["_text"]
	return str
end

-- does not work
p.getdatatest = function()
	local slotdata = mw.slots.slotTemplates( "ws-page-props", "Boek/-100102193" )
	mw.logObject( slotdata );
	local str = slotdata["Book"][1]["TitelNr"]["_text"]
	return str
end


--[[
test to show comparison callParserFunction and extensionTag
]]
p.form1 = function(frame)
	-- test of frame:callParserFunction
	-- {{#tag:form||id=bla|action=get}}
	local content = 'Test'
	local formparams = { 'form', content, id = 'bla', action = 'get' }
	local str = frame:callParserFunction( '#tag', formparams )
	return str
end

--[[
Makes more sense than using callParserFunction
but "equivalent to a call to frame:callParserFunction() with function name '#tag' "
]]--
p.form2 = function(frame)
	-- frame:extensionTag( name, content, args )
	local content = 'Test'
	local tag = 'form'
	local args = { id = 'bla', action = 'get' }
	local str = frame:extensionTag( tag, content, args )
	return str
end

return p