Page 1 of 1

[LUA] Post Create Help

Posted: Wed Sep 25, 2024 3:34 pm
by zaferbey4949
Hello, I am trying to create a post with postcreate using Lua.

forumid = req.post.category,
title = req.post.title,
content = req.post.content,
thumb = req.post.thumb,

It adds, but I couldn't find how to save something in var (videoid) style.

videoid = req.post.var_videoid,
I tried this way but it doesn't add it.

Code: Select all

	if env.userid == 0 or not env.is_admin then
		url.redirect('/')
	end

	if (url.map("/admin")) then
		url.redirect('/')
	end


if (url.map("/admin/")) then
    if (req.method == "POST") then
        local param = {
            forumid = req.post.category,
            title = req.post.title,
            content = req.post.content,
            thumb = req.post.thumb,
			videoid = req.post.var_videoid,
			bolum = req.post.var_bolum,
            status = 1,
        }
        title = param.title
        content = param.content
        if title and content then
            if title == '' or content == '' or param.thumb == '' or param.videoid == '' or param.bolum == '' then
                print([[<div class='alert alert-danger'> <i class='fa fa-times-circle d-none d-md-inline-block'></i> Başlık Girilmedi</div>]])
            elseif #title < 5 or #title > 900 then
                print([[<div class='alert alert-danger'> <i class='fa fa-times-circle d-none d-md-inline-block'></i> Geçersiz bölüm başlığı uzunluğu (en az 10, en fazla 100) </div>]])
            elseif #content < 100 then
                print([[<div class='alert alert-danger'> <i class='fa fa-times-circle d-none d-md-inline-block'></i> Bölüm bilgi kısmı çok kısa </div>]])
            else
                local is_ok = api.post_create(param)
                if is_ok then
                    url.redirect('/admin/')
                end
            end
        end
    end

    print([[
    <form name="form" action="" method="post">
	<div id="content">
		<div class="wrapper">
			<div class="pd-expand"></div>
	<div class="postbody">
	<article id="post-10662" class="post-10662">
			
	<div class="releases hothome"><h2><i class="fa-solid fa-plus"></i> Bölüm Ekle</h2>
	<div class="vl"> <a href="/admin">Admin Panel</a></div>
	</div>
	<div class="entry-content">
	</div>

	<div class="single-info bixbox">

	<div class="desc mindes">
	
	
					<p class="comment-form-url">
				<label for="url"><i class="fa-brands fa-cuttlefish"></i> Çizgi Film Adı</label> <br/>
				<input id="url" name="name" type="text" value="" size="30" maxlength="200"  /></p><hr>
					

				<p class="comment-form-url">
				<label for="url"><i class="fa-solid fa-image"></i> Çizgi Film Resim</label> <br/>
				<input id="url" name="thumb" type="text" value="" size="30" maxlength="200" /></p>	<hr>					


				<p class="comment-form-url">
				<label for="url"><i class="fa-solid fa-comment"></i> Çizgi Film bilgi</label> 
				<input id="url" name="content" type="text" value="" size="30" maxlength="999" /></p><hr>

				<p class="comment-form-url">
				<label for="url"><i class="fa-solid fa-inbox"></i> Çizgi Film Bölüm</label> 
				<input id="url" name="bolum" type="text" value="" size="30" maxlength="200"/></p><hr>


				<p class="comment-form-url">
				<label for="url"><i class="fa-brands fa-youtube"></i> Çizgi Film videoid</label> 
				<input id="url" name="videoid" type="text" value="" size="30" maxlength="200"/></p><hr>

				<p class="comment-form-url">
				<label for="url"><i class="fa-solid fa-list"></i> Çizgi Film kategori</label> <br/>
				<select style="width: 690px">
	
	
    ]])
		local excluded_ids = {25166, 25164, 25237, 25295, 25211, 25177,25187,25188,25189,25186,25190,25167,} --Görünmesini istemediğin forumların ID leri
		local cat_check, cat_check_list, cat_check_stats = api.forum_info()
		cat_total = cat_check_stats['total']
		local cat_check1, cat_list, cat_stats = api.forum_info({limit=cat_total})
		table.insert(cat_list, 1, cat_list[0])
		for loopindex, category in ipairs(cat_list) do
				-- Kategori ID'sinin hariç tutulup tutulmadığını kontrol etme
				local is_excluded = false
				for _, excluded_id in ipairs(excluded_ids) do
					if category['id'] == excluded_id then
						is_excluded = true
						break
					end
				end
				
			 if not is_excluded then	
			print(string.format('<option value="%s">%s</option>', category['id'], category['name']))
			end
		end	
    print([[
			   </select> </p><br>
				
				<div class="float-right">
					<button type="submit"class="buttonClass"">Ekle</button>
				  </div>
			</form>								
				</div>
	</div>
	</div>
    </form>
    ]])
end

Re: [LUA] Post Create Help

Posted: Wed Oct 02, 2024 9:30 pm
by Francisco2
Hello! Please see this:
viewtopic.php?p=2393#p2393

In your case, the syntax would be:

Code: Select all

....
        local param = {
            forumid = req.post.category,
            title = req.post.title,
            content = req.post.content,
            thumb = req.post.thumb,
            var = {
			videoid = req.post.var_videoid,
			bolum = req.post.var_bolum
            }
            status = 1
        }
....

Re: [LUA] Post Create Help

Posted: Thu Oct 03, 2024 9:53 am
by zaferbey4949
ok. thank u <3