람보 님께서 제작해주신 랜덤게시글 모듈을 사용중입니다

혹시, 랜덤 게시글을 가져올 때 최근 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" />

  • ? ?
    해당 쿼리에 칼럼 추가했는데, 아직도 30일 이전의 글을 가져오면 빈페이지가 떠버리네요
    답변 감사드립니다 ㅠㅠ
  • ? ?
    추가해서 넣으신 리턴 구문은 삭제하시구요
    쿼리하기전에 옵션값을 넣어 30일이전글만 가져오게 처리해보세요
    예) $args->regdate = '20180227000000';