람보 님께서 제작해주신 랜덤게시글 모듈을 사용중입니다
혹시, 랜덤 게시글을 가져올 때 최근 30일 등 조건을 추가할 순 없을까요?
randocument.view.php 에서
" $oDocument = getModel('document')->getDocument($output->data->document_srl);
if($oDocument->get('regdate') < date('YmdHis', strtotime('-30 day'))) return $output; "
를 추가해보았으나, 30일이 지난 게시글을 가져오면 빈화면으로 표시되어버려서
30일이 경과한 게시물일 경우엔 다시 새로운 쿼리를 가져오도록 return 을 해주어야 할 것 같은데.. ㅠㅠ
아니면 php 가 아닌 xml 에서 작성일 기준으로 30일이 안된 쿼리만 가져올 수는 없을까요?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
class randocumentView extends randocument
{
function init()
{
$template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
if(!is_dir($template_path)||!$this->module_info->skin)
{
$this->module_info->skin = 'default';
$template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin);
}
$this->setTemplatePath($template_path);
}
function dispRandocumentRand()
{
if(!$this->module_info->seleted_module_srl)
{
return new Object(-1, '설정을 불러 올 수 없습니다.');
}
$args = new stdClass();
$args->module_srls = $this->module_info->seleted_module_srl;
$args->sort_index = 'rand()';
$output = executeQuery('randocument.getRandocumentToDocumentSrl', $args);
if(!$output->toBool())
{
return $output;
}
// 30일이 지난 글은 져올 수 없습니다
$oDocument = getModel('document')->getDocument($output->data->document_srl);
if($oDocument->get('regdate') < date('YmdHis', strtotime('-30 day'))) return
if($output->data->document_srl)
{
$oDocument = getModel('document')->getDocument($output->data->document_srl);
$link = html_entity_decode($oDocument->getPermanentUrl());
Context::set('getlink', $link);
}
else
{
Context::set('getlink', null);
}
if($this->module_info->test_mode === 'yes')
{
Context::set('document', $oDocument);
}
else
{
Context::set('document', null);
}
$this->setTemplateFile('rand');
}
}
|
cs |
getRandocumentToDocumentSrl 쿼리에 regdate옵션을 넣으셔야 해요.
<condition operation="more" column="regdate" var="regdate" pipe="and" />