Author Topic: Cara membuat placeholder di MODX Evo  (Read 2991 times)

0 Members and 1 Guest are viewing this topic.

Offline darmant

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Cara membuat placeholder di MODX Evo
« on: May 14, 2012, 06:53:18 PM »
Halo Semua,

Aku ada permasalah gini ini, kmren aku dapet tutorial dari tautan ini http://codingpad.maryspad.com/2010/01/15/modx-custom-snippet-api/

Nah aku coba buat simple snippet dngan nama "TestSnippet" :
Code: [Select]
<?php
global $modx;

$modx->setPlaceholder('test''Haloo test'); 
$modx->parseChunk('nama_chunk'$modx->placeholders'[+''+]');
?>


trus di chunknya aku coba gini panggilnya :
Code: [Select]
[[TestSnippet]]
[+test+]

Kok g muncul ya? pdahal ketika aku coba debug dengan "print_r($modx->placeholders)" muncul nilainya, saya sudah coba cari referensi tutorialnya tapi sulit nemukanya, mungkin karena keywordnya yang salah mungkin  ;D, jadi mohon bantuannya.

NB: jangan menyarankan untuk pindah ke MODX Revo, kalu itu bisa pasti sudah saya lakukan  ;)
« Last Edit: May 14, 2012, 06:57:55 PM by darmant »
Agung
Web Developer | TW : @darmanto_agung | FB : http://facebook.com/darmanto.agung

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 345
  • Karma: +1/-0
  • Less is more
    • Virtudraft Intermedia Telematika
Re: Cara membuat placeholder di MODX Evo
« Reply #1 on: May 16, 2012, 09:42:32 PM »
Sebenernya saya sudah buat juga versi Endonesa-nya:
http://modx-id.com/references/tutorial/custom-database-part-1-data-schema-snippet-dan-chunk.html
tapi yaaa... untuk Revo :P

Kalo evo, coba begini:
Code: (php) [Select]
<?php
// method ini buatanmu sendiri, yah...
$contents $myObject->getContent();

//intinya, jadinya entar kurang lebih kayak begini:
$contents = array(
    
'nama' => 'darmant',
    
'jenkel' => 'flexibel'
);

$output $modx->parseChunk('chunkSaya'$contents);
return 
$output;

Setelah itu, bikin chunk chunkSaya yang isinya:
Code: (html) [Select]
<p>Halo [+nama+], jenis kelaminmu: [+jenkel+].</p>

Kalo mau nama chunk-nya flexibel, agar panggilan snippetnya kayak begini:
Code: [Select]
[[TestSnippet? &tpl=`chunkSayaKedua`]]
Bagian akhir outputnya diubah begini:
Code: (php) [Select]
<?php
$tpl 
= !empty($tpl) ? $tpl 'chunkSaya'// default fallback ke nama chunk "chunkSaya"
$output $modx->parseChunk($tpl$contents);
return 
$output;
« Last Edit: May 16, 2012, 09:46:51 PM by goldsky »
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!

Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets | IE 6 must die !

Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

PING ME ON TWITTER @_goldsky

Offline darmant

  • Newbie
  • *
  • Posts: 20
  • Karma: +0/-0
Re: Cara membuat placeholder di MODX Evo
« Reply #2 on: May 17, 2012, 06:34:19 PM »
Oh harus di return valuenya dengan chunk yang terkait ya.. aku pikir dengan tanpa nilai pengembalian dari chunk itu sendiri sudah bisa dibaca. Ok thanks bang infonya  ;)
Agung
Web Developer | TW : @darmanto_agung | FB : http://facebook.com/darmanto.agung

Offline goldsky

  • tweets @_goldsky
  • Administrator
  • Sr. Member
  • *****
  • Posts: 345
  • Karma: +1/-0
  • Less is more
    • Virtudraft Intermedia Telematika
Re: Cara membuat placeholder di MODX Evo
« Reply #3 on: May 18, 2012, 08:21:48 AM »
same2 :)

Sent from my MB525 using Tapatalk 2
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!

Security, security, security! | Indonesian MODx Forum | MODx Revo's cheatsheets | MODx Evo's cheatsheets | IE 6 must die !

Author of Easy 2 Gallery 1.4.x, PHPTidy, spieFeed, FileDownload R, Upload To Users CMP, Inherit Template TV, LexRating, ExerPlan, Lingua, virtuNewsletter, Grid Class Key, SmartTag, prevNext

PING ME ON TWITTER @_goldsky