Author Topic: [ask] archivist -> Grouping berdasarkan tahun  (Read 303 times)

0 Members and 1 Guest are viewing this topic.

Offline dvio

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
[ask] archivist -> Grouping berdasarkan tahun
« on: December 04, 2011, 08:47:06 AM »
Hi modxers,

Ternyata masih sepi aja ya, di Indonesia masih jarang apa ya yg pake modx  ???

Ke masalah:

Saya ingin menampilkan arsip per tahun menggunakan archivist, hasil yg diinginkan kira2 seperti berikut:

Code: [Select]
<ul>
  <li><a href="link">2011</a>
    <ul class="some-class">
      ...
      <li><a href="link">October</a></li>
      <li><a href="link">September</a></li>
      ...
    </ul>
  </li>
  <li><a href="link">2010</a>
    <ul class="some-class">
      ...
      <li><a href="link">October</a></li>
      <li><a href="link">September</a></li>
      ...
    </ul>
  </li>
  ...
</ul>

Di archivist yg saya tahu cuma ada 1 template untuk menampilkan hasil,

Gimana ya caranya supaya dapat hasil kayak di atas menggunakan archivist?

Ada ide?

Terima kasih sebelumnya

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +1/-0
  • Less is more
    • Virtudraft Web
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #1 on: December 04, 2011, 06:51:12 PM »
iya, mungkin karena help-nya masih bahasa enggres semua. :P

anyway,
snippet call-nya yang dipakai bagaimana?
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
Apache 2.0.63 (Win32)
PHP Version 5.2.9-2
MySQL 5.0.87 (3306)
Security, security, security!
IE 6 must die !
Indonesian Forums
Cheatsheets: Revo's, Evo's
Easy 2 Gallery 1.4.x
Board || GIT || WIKI || Examples || Donate
spiefeed || Doc || GIT
» tutorial, tips, & tricks to here: http://modx-linx.net

Offline dvio

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #2 on: December 04, 2011, 09:35:05 PM »
Snippet call-nya standar aja bos,

Code: [Select]
[[!Archivist? &target=`52` &parents=`2` &tpl=`default.archivlist.tpl`]]

Yg bingung, nampilinnya, gimana supaya bisa ditampilkan jd begini:
Code: [Select]
2011
---- ...
---- Agustus
---- ...
2010
---- ...
---- Agustus
----...
...

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +1/-0
  • Less is more
    • Virtudraft Web
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #3 on: December 05, 2011, 06:17:58 PM »
Sepertinya parameter snippetnya harus ditambahin, bos.
http://rtfm.modx.com/display/ADDON/Archivist.Archivist

Code: [Select]
[[!Archivist? &target=`52` &parents=`2` &tpl=`default.archivlist.tpl` &...=`...`]]

Saya sih belum pernah pake archivist.
Tapi kalo yang di http://modx-linx.net, buatan ndewe. :P
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
Apache 2.0.63 (Win32)
PHP Version 5.2.9-2
MySQL 5.0.87 (3306)
Security, security, security!
IE 6 must die !
Indonesian Forums
Cheatsheets: Revo's, Evo's
Easy 2 Gallery 1.4.x
Board || GIT || WIKI || Examples || Donate
spiefeed || Doc || GIT
» tutorial, tips, & tricks to here: http://modx-linx.net

Offline crackers

  • Administrator
  • Full Member
  • *****
  • Posts: 150
  • Karma: +0/-0
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #4 on: December 05, 2011, 10:53:47 PM »
yep klo susah bikin sendiri ajah bro seperti saran master goldsky just write you rphp code kok simple :D heheheheh

Offline dvio

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #5 on: December 06, 2011, 12:12:56 AM »
Sepertinya parameter snippetnya harus ditambahin, bos.
http://rtfm.modx.com/display/ADDON/Archivist.Archivist

Code: [Select]
[[!Archivist? &target=`52` &parents=`2` &tpl=`default.archivlist.tpl` &...=`...`]]

Saya sih belum pernah pake archivist.
Tapi kalo yang di http://modx-linx.net, buatan ndewe. :P

Klo setelah dipelajari kayaknya ga bisa dengan parameter bawaan, harus bikin parameter dan processor baru, karena template yg disediain cuma 1,  cuma buat create row aja. BTW arsip yg di http://modx-linx.net mantap tu bos, persis seperti yg diinginkan, pake apa itu bikinnya, custom kah? bagi2 dong :D

yep klo susah bikin sendiri ajah bro seperti saran master goldsky just write you rphp code kok simple :D heheheheh

Betul brader, saya juga rencana bikin sendiri aja, masalahnya saya belom belajar php ... hehehe :D

Ada ide mulai dari mana? ngefork archivist, ato dr scratch aja?

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +1/-0
  • Less is more
    • Virtudraft Web
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #6 on: December 06, 2011, 04:27:33 AM »
waduh... agak susah ngejelasinnya...  ;D

kalo yang gw bikin di modx-linx, archive-nya berjalan pake ajax.
jadi, gw bikin snippet processor dulu.
snippetnya gw taro di halaman khusus gw sediain, dengan template yang kosong melompong, hanya sekedar sebagai akses URL ajax-nya.
trus, di dalam snippet, manggil Class untuk ngeluarin method yang mengolah tanggalan.
Tanggalannya berdasarkan Custom Database dari arsip link-link yang diinput.

Kalo sejauh ini ngerti, ini processornya:
Code: php [Select]

<?php

$archiveLinks = $ml->archiveLinks('2');

$output = '
                <div class="filter-nav">
                    <div class="nav-title">Archives</div>
                        <div class="archives">
                        ' . $archiveLinks . '
                        </div>
                </div>
                ';

echo $output;

exit();


dibawah ini methods-nya:
Code: php [Select]

    /**
     * Links archive
     * @param   string  $href   redirect url
     * @return  string  formated navigation
     */
    public function archiveLinks($urlId) {
        $c = $this->modx->newQuery('Link');
        $c->where(array('approved' => 1));

        if ($this->modx->getCount('Link', $c) < 1) {
            return FALSE;
        }

        $links = $this->modx->getCollection('Link', $c);

        $archives = array();
        foreach ($links as $link) {
            $archives[] = $link->get('postedon');
        }

        natsort($archives);
        rsort($archives);

        $arcs = array();
        foreach ($archives as $archive) {
            if (!empty($arcs[strftime('%Y', $archive)][strftime('%m', $archive)])) {
                $arcs[strftime('%Y', $archive)][strftime('%m', $archive)] = $arcs[strftime('%Y', $archive)][strftime('%m', $archive)] + 1;
            } else {
                $arcs[strftime('%Y', $archive)][strftime('%m', $archive)] = 1;
            }
        }

        $output = '' . "\n";
        foreach ($arcs as $year => $months) {
            $output .= "\t" . '<div class="archive-year">' . $year . '</div>' . "\n";
            $output .= "\t\t" . '<ul class="archive-year-leap">' . "\n";
            ksort($months);
            foreach ($months as $month => $num) {
                $href = $this->modx->makeUrl($urlId, null, array('arc' => $year . '-' . $month), 'full');
                $output .= "\t\t\t" . '<li><a href="' . $href . '"><span class="archive-month">' . $this->_monthName($month) . ' (' . $num . ')</span></a></li>' . "\n";
            }
            $output .= "\t\t" . '</ul>' . "\n";
        }

        return $output;
    }

    private function _monthName($mo) {

        $monthName = '';
        switch ($mo) {
            case '01':
                $monthName = 'January';
                break;
            case '02':
                $monthName = 'February';
                break;
            case '03':
                $monthName = 'March';
                break;
            case '04':
                $monthName = 'April';
                break;
            case '05':
                $monthName = 'May';
                break;
            case '06':
                $monthName = 'June';
                break;
            case '07':
                $monthName = 'July';
                break;
            case '08':
                $monthName = 'August';
                break;
            case '09':
                $monthName = 'September';
                break;
            case '10':
                $monthName = 'October';
                break;
            case '11':
                $monthName = 'November';
                break;
            case '12':
                $monthName = 'December';
                break;
            default:
                break;
        }
        return $monthName;
    }


'Link' adalah custom database class yg gw bikin.
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
Apache 2.0.63 (Win32)
PHP Version 5.2.9-2
MySQL 5.0.87 (3306)
Security, security, security!
IE 6 must die !
Indonesian Forums
Cheatsheets: Revo's, Evo's
Easy 2 Gallery 1.4.x
Board || GIT || WIKI || Examples || Donate
spiefeed || Doc || GIT
» tutorial, tips, & tricks to here: http://modx-linx.net

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +1/-0
  • Less is more
    • Virtudraft Web
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #7 on: December 06, 2011, 04:32:19 AM »
uhm... ato gini deh... yang archivist aja ntar gw tambahin parameternya, gw pull request ke splittingred.
mas @dvio maunya hasil akhirnya ngurut bagaimana?
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
Apache 2.0.63 (Win32)
PHP Version 5.2.9-2
MySQL 5.0.87 (3306)
Security, security, security!
IE 6 must die !
Indonesian Forums
Cheatsheets: Revo's, Evo's
Easy 2 Gallery 1.4.x
Board || GIT || WIKI || Examples || Donate
spiefeed || Doc || GIT
» tutorial, tips, & tricks to here: http://modx-linx.net

Offline dvio

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #8 on: December 06, 2011, 05:18:16 AM »
uhm... ato gini deh... yang archivist aja ntar gw tambahin parameternya, gw pull request ke splittingred.
mas @dvio maunya hasil akhirnya ngurut bagaimana?

Wah mantap tu bos kalo bisa diusahain :D

Sebenarnya yg diharapkan seperti ini
Code: [Select]
...
...
<div class="div1">
    <div class="div2">
        <h4>2011</h4>
        <div class="div3">
            <ul>
                ...
                ...
                <li><a href="#">Mei</a></li>
                <li><a href="#">April</a></li>
                ...
                ...
            </ul>
        </div>
    </div>
</div>
<div class="div1">
    <div class="div2">
        <h4>2010</h4>
        <div class="div3">
            <ul>
                ...
                ...
                <li><a href="#">Mei</a></li>
                <li><a href="#">April</a></li>
                ...
                ...
            </ul>
        </div>
    </div>
</div>
...
...

Jadi diharapkan ada setidaknya 2 template, template buat row (bulan) dan template buat group (tahun).

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +1/-0
  • Less is more
    • Virtudraft Web
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #9 on: December 06, 2011, 06:58:39 PM »
jadi tahunnya descending, bulannya ascending?

Sent from my MB525 using Tapatalk
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
Apache 2.0.63 (Win32)
PHP Version 5.2.9-2
MySQL 5.0.87 (3306)
Security, security, security!
IE 6 must die !
Indonesian Forums
Cheatsheets: Revo's, Evo's
Easy 2 Gallery 1.4.x
Board || GIT || WIKI || Examples || Donate
spiefeed || Doc || GIT
» tutorial, tips, & tricks to here: http://modx-linx.net

Offline dvio

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #10 on: December 06, 2011, 09:43:39 PM »
Dua2nya descending dong bos :D
Code: [Select]
2011
---- Desember
---- November
---- Oktober
---- September
---- ...
2010
---- Desember
---- November
---- Oktober
---- ....
....

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +1/-0
  • Less is more
    • Virtudraft Web
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
Apache 2.0.63 (Win32)
PHP Version 5.2.9-2
MySQL 5.0.87 (3306)
Security, security, security!
IE 6 must die !
Indonesian Forums
Cheatsheets: Revo's, Evo's
Easy 2 Gallery 1.4.x
Board || GIT || WIKI || Examples || Donate
spiefeed || Doc || GIT
» tutorial, tips, & tricks to here: http://modx-linx.net

Offline dvio

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #12 on: December 07, 2011, 01:41:05 AM »
Wah mantap bos, saya coba dulu ya, nanti saya laporin di sini :D

Offline dvio

  • Newbie
  • *
  • Posts: 26
  • Karma: +0/-0
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #13 on: December 07, 2011, 03:30:07 AM »
Saya sudah coba dan berhasil bos, terima kasih.

Cuma td ada sdikit trable pas apdet archivistnya, udah diupdate di core/.../snippet.archivist.php - nya, di packagenya, di zip nya, clear cache, flush permission, hapus semua .cache.php, install ulang archivist masih aja ga mau update tu snippet.

Akhirnya saya update aja snippet di managernya ... jalan deh :D

Sayang ga bisa tunjukin hasilnya soalnya masih di localhost :D

Mantap bos, mudah-an lolos pull n masuk ke versi berikutnya  ;D

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
  • Karma: +1/-0
  • Less is more
    • Virtudraft Web
Re: [ask] archivist -> Grouping berdasarkan tahun
« Reply #14 on: December 07, 2011, 03:31:14 AM »
sama-sama.
sekedar tambahan, locale-nya juga bisa diset.

Code: [Select]
[[!Archivist? &target=`2` &parents=`3` &locale=`Indonesian` &groupByYear=`1`]]
Rico
Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison
MODx is great, but knowing how to use it well makes it perfect!
Apache 2.0.63 (Win32)
PHP Version 5.2.9-2
MySQL 5.0.87 (3306)
Security, security, security!
IE 6 must die !
Indonesian Forums
Cheatsheets: Revo's, Evo's
Easy 2 Gallery 1.4.x
Board || GIT || WIKI || Examples || Donate
spiefeed || Doc || GIT
» tutorial, tips, & tricks to here: http://modx-linx.net