| CMS/프레임워크 | Rhymix 2.1 |
|---|---|
| 개발 언어 | PHP 8.4 |
| 문제 페이지 주소 | 비공개 (검색로봇) |
테스트 중인데요
데이터를 전혀 못불러오고있습니다. ㅠ
module.xml 코드 고요.
<?xml version="1.0" encoding="utf-8"?>
<module version="1.0">
<actions>
<!-- 기본 view -->
<action name="dispBanjjakclassIndex"
class="Controllers\Index"
type="view"
index="true"
standalone="true" />
<!-- controller -->
<action name="procBanjjakclassLoadData"
class="Controllers\IndexController"
type="controller"
standalone="true" />
</actions>
<menus>
<menu name="banjjakclass">
<title xml:lang="ko">반짝클래스</title>
</menu>
</menus>
</module>
IndexController.php 코드입니다.
<?php
namespace Banjjakclass\Controllers;
use Rhymix\Framework\Context;
use DB;
class IndexController extends \Banjjakclass
{
public function procBanjjakclassLoadData()
{
$class_id = (int)(Context::get('class_id') ?? 1);
$type = Context::get('type') ?? 'test';
$db = DB::getInstance();
$row = $db->select('rx_banjjak_class_data')
->where('class_id', $class_id)
->where('type', $type)
->getRow();
$result = $row ? [
'success' => true,
'data' => json_decode($row->data_json, true),
'updated_at' => $row->updated_at
] : [
'success' => false,
'msg' => '데이터 없음'
];
header('Content-Type: application/json; charset=utf-8');
echo json_encode($result, JSON_UNESCAPED_UNICODE);
exit;
}
}
banjjakclass.class 코드입니다.
<?php
class Banjjakclass extends ModuleObject
{
function moduleInstall() { return new Object(); }
function checkUpdate() { return false; }
function moduleUpdate() { return new Object(); }
function recompileCache() { }
}
spl_autoload_register(function ($class) {
if (strpos($class, 'Banjjakclass\\') === 0) {
$path = __DIR__ . '/' . str_replace('\\', '/', substr($class, strlen('Banjjakclass\\'))) . '.php';
if (file_exists($path)) {
require_once $path;
}
}
});
/public_html/modules/banjjakclass/views/index.html 코드입니다.
<h2>{$msg}</h2>
<p>이 문구가 보이면 view 연결 성공입니다.</p>
<button id="loadBtn">서버 데이터 불러오기</button>
<!--@literal-->
<script>
document.getElementById('loadBtn').addEventListener('click', async function() {
const token = window.csrf_token ||
document.querySelector('meta[name="csrf-token"]')?.content || '';
try {
const res = await fetch('/index.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest'
},
body: new URLSearchParams({
module: 'banjjakclass',
act: 'procBanjjakclassLoadData',
class_id: 1,
type: 'test',
xe_validator_id: token
})
});
if (!res.ok) throw new Error('HTTP ' + res.status);
const data = await res.json();
alert('✅ 서버 응답:\n' + JSON.stringify(data, null, 2));
} catch (err) {
alert('❌ 오류:\n' + err);
}
});
</script>
<!--@endliteral-->
https://sub-teacher.com/index.php?module=banjjakclass
테스트 해보면 아래와같이 나옵니다.

전체 파일은 압축해서 올렸습니다. gtp가 라이믹스는 너무 모르네요. ㅠㅠㅠㅠ도와주십쇼
댓글 4
차라리 압축해서 올려주시는게 좋을것같네요
본문삽입을 안했네요.^^
음 솔직히 말씀드리면 그냥 새로 짜는게 나을정도인데요.
수정방법을 알려드려도 이 뒤에 제대로 사용하실 수 없으실것같구요.
라이믹스 코드 구조를 제대로 모르는 GPT한테 물어보시는것보다 필요한 모듈이 진짜 있으시면 의뢰 통해서 해결하시는것도 방법입니다.
GPT가 써준 건가요?
IndexController.php는 라이믹스와 전혀 상관없는 코드로 가득차 있으니 파일을 통째로 지우시고요,
banjjakclass.class.php도 대부분 쓸데없는 코드입니다. 여기는 class 껍데기만 남기고 내용은 모두 비우세요.
그나마 banjjakclass.controller.php에서 작업을 좀 진행하셨던 것 같은데,
module.xml에서는 거기 말고 엉뚱한 파일만 가리키고 있으니...
module.xml에서 class="..." 속성을 모두 삭제하면 님이 controller 쪽으로 연결될 것 같습니다.