Helper Tambahan yang Tidak ada dalam Dokumentasi PopojiCms
- Administrator
- Helper page
- 3635 Kali Dilihat
- 2 Komentar
Helper Tambahan yang Tidak ada dalam Dokumentasi PopojiCms
Berikut adalah helper tema untuk melengkapi dokumentasi PopojiCms. Helper tema yang didokumentasikan pada halaman ini pada dasarnya ada dalam file PopojiCms, namun belum didokumentasikan pada dokumentasi helper tema PopojiCms.
Snippet Untuk menampilkan bulan dalam versi pendek:
<?=$this->pocore()->call->podatetime->tgl_indo(substr($recent_side['date'],8,2));?> //Hari
<?=$this->pocore()->call->podatetime->getBulanShrt(substr($recent_side['date'],5,2));?> //Bulan
<?=$this->pocore()->call->podatetime->tgl_indo(substr($recent_side['date'],0,4));?> //Tahun
Snippet Untuk menu dropdown bahasa:
<?php
$languages = $this->language()->getLanguage('ASC');
foreach($languages as $language){
echo "<li><a href='?lang=".$language['code']."'>".$language['title']."</a>";
}
?>
Jika penasaran silahkan buka file header.php tema hueman.
Mengatasi error balas kontak dengan protokol SMTP
Rubah protokol smtp pada file berikut:
po-content/component/contact/admin_contact.php
dibaris :
$this->pomail->SMTPSecure = 'ssl';
ganti jadi :
$this->pomail->SMTPSecure = 'tls';
Bagi yang menggunakan Gmail sebagai email admin, baca tentang allow less secure apps dan xoauth melalui link dibawah:
https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Masalah error User level: https://www.facebook.com/groups/popojicms/permalink/1029867403755975/, custom role user silahkan edit sourcenya di po-content/component/user/admin_user.php
Menambahkan ancor atau class href=""
pada menu:
<?php
echo $this->menu()->getFrontMenu(WEB_LANG, 'class="nav navbar-nav"', '', 'class="dropdown-menu"', 'class="dropdown-toggle hvr-bounce-to-bottom" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"');
?>
Lalu ganti file : po-includes/core/vendor/dynamicmenu/front_menu.php
dengan file "front_menu2.php
" berikut:
<?php
/**
*
* - PopojiCMS Core Vendor
*
* - File : front_menu.php
* - Version : 1.0
* - Author : Gawibowo edited by Jenuar Dalapang
* - License : MIT License
*
*
* Ini adalah library untuk mengenerate nested lists.
* This is library for generating nested lists.
*
* Contoh untuk penggunaan class ini
* Example for uses this class
*
*
* $instance = new FrontMenu;
* $menu = $instance->menu(1, 'class="nav" id="side-menu"', '', 'class="nav nav-second-level"');
* echo $menu;
*
*/
class FrontMenu
{
protected $podb;
/**
* Constructor. Initialize database connection
*/
public function __construct()
{
$this->pdo = new PDO("mysql:host=".DATABASE_HOST.";dbname=".DATABASE_NAME."", DATABASE_USER, DATABASE_PASS);
$this->podb = new FluentPDO($this->pdo);
}
/**
* Get menu from database, and generate html nested list
*
* @param int $group_id
* @param string $attr, $attrs, $attrss
* @return string
*/
public function menu($group_id, $attr = '', $attrs = '', $attrss = '', $attrsss = '')
{
global $_;
$selectlang = (isset($_COOKIE['lang']) ? $_COOKIE['lang'] : 'id');
include_once DIR_CON."/lang/main/".$selectlang.".php";
include_once "tree.php";
$tree = new Tree;
$base_root = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] && !in_array(strtolower($_SERVER['HTTPS']),array('off','no'))) ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].$_SERVER["PHP_SELF"];
$base_url = preg_replace("//(index.php$)/", "", $base_root);
$menu = $this->podb->from('menu')
->where('group_id', $group_id)
->where('active', 'Y')
->orderBy(array('parent_id ASC', 'position ASC'))
->fetchAll();
foreach ($menu as $row) {
if (!preg_match("~^(?:f|ht)tps?://~i", $row['url'])) {
$menu_url = $base_url.'/'.$row['url'];
} else {
$menu_url = $row['url'];
}
if ($row['parent_id'] == 0) {
if ($row['class'] != '') {
$label = '<a href="' . $menu_url . '" '.($row['target'] != 'none' ? 'target="' . $row['target'] . '"' : '').'>';
} else {
$label = '<a href="' . $menu_url . '" '.($row['target'] != 'none' ? 'target="' . $row['target'] . '"' : '').'>';
}
} else {
if ($row['class'] != '') {
$label = '<a ' . $attrsss . ' href="' . $menu_url . '" '.($row['target'] != 'none' ? 'target="' . $row['target'] . '"' : '').'>';
} else {
$label = '<a ' . $attrsss . ' href="' . $menu_url . '" '.($row['target'] != 'none' ? 'target="' . $row['target'] . '"' : '').'>';
}
}
$label .= $row['title'];
$label .= '</a>';
$li_attr = '';
$tree->add_row($row['id'], $row['parent_id'], $li_attr, $label);
}
$menu = $tree->generate_list($attr, $attrs, $attrss);
return $menu;
}
}
Fatal error: Allowed memory size
Hal tersebut menyebabka server sering down karena kehabisan memory atau resources akibat to many connection db in core.php
. Biasanya diketahui dengan munculnya error:
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 20480 bytes) in /home/numpanglewat/public_html/po-includes/core/vendor/fluentpdo/SelectQuery.php on line 126
Untuk mengatasi hal diatas silahkan replace po-includes/core/core.php
dengan merujuk kepada link berikut:
https://github.com/PopojiCMS/PopojiCMS/blob/master/po-includes/core/core.php
Lanjutkan dengan main setting:
php.ini:memory_limit: 32M
tambah jadi:memory_limit: 128M
atau jadimemory_limit: 256M
.htaccess:<IfModule php7_module>
php_flag display_errors On
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 32M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
php_value upload_max_filesize 2M
</IfModule>
Jadi:<IfModule php7_module>
php_flag display_errors On
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 128M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php56"
php_value upload_max_filesize 2M
</IfModule>
Snippet untuk menampilkan konten halaman:
<?php
$pages = $this->pocore()->call->podb->from('pages')
->select(array('pages_description.title', 'pages_description.content'))
->leftJoin('pages_description ON pages_description.id_pages = pages.id_pages')
->where('pages.seotitle', 'seotitle-pages') /** seotitle-pages silahkan ganti dengan seotitle halaman yang ingin ditampilkan **/
->where('pages_description.id_language', WEB_LANG_ID)
->where('pages.active', 'Y')
->limit(1)
->fetch();
?>
Judul Halaman:
<?=$this->e($pages['title']);?>
Gabar Halaman:
<?=$this->e($pages['picture']);?>
Konten Halaman:
<?=htmlspecialchars_decode(html_entity_decode($this->e($pages['content'])));?>
Lanjutkan dengan menambahkan snippet pada po-content/component/home/home.php
$router->match('GET|POST', '/judul-halaman', function() use ($core, $templates) {
$lang = $core->setlang('home', WEB_LANG);
$info = array(
'page_title' => 'Judul-halaman',
'page_desc' => $core->posetting[2]['value'],
'page_key' => $core->posetting[3]['value'],
'social_mod' => 'Judul-halaman',
'social_name' => $core->posetting[0]['value'],
'social_url' => $core->posetting[1]['value'].'/judul-halaman',
'social_title' => 'Judul-halaman',
'social_desc' => $core->posetting[2]['value'],
'social_img' => $core->posetting[1]['value'].'/'.DIR_INC.'/images/favicon.png'
);
$adddata = array_merge($info, $lang);
$templates->addData(
$adddata
);
echo $templates->render('judul-halaman', compact('lang'));
});
Function untuk menampilkan popular_side dalam jumlah hari tertentu
Pada po-content/widget/post/post.php
tambahkan where baru diatas orderby:
Populer 3 hari terakhir:
->where('post.publishdate', date('Y-m-d', strtotime('-3 days')))
Untuk populer minggu ini :
->where('DATE(post.publishdate)', 'DATE_SUB(DATE("'.date('Y-m-d').' 00:00:00"), INTERVAL 1 WEEK)')
Untuk popular bulan ini:
->where('MONTH(post.publishdate) = ?', date('m'))
Menampilkan post popular percategory:
<?php
$post = array();
$categorys = $this->pocore()->call->podb->from('post_category')
->where('id_category', $this->post()->getCategoryParentTree('1'))
->orderBy('id_post_category DESC')
->fetchAll();
foreach($categorys as $cat){
$if_post = $this->post()->getPostById($cat['id_post'], WEB_LANG_ID);
if (!empty($if_post['active'])) {
$post[] = $this->post()->getPostById($cat['id_post'], WEB_LANG_ID);
}
}
$popular = $this->post()->arrayOrderBy($post, 'hits', SORT_DESC);
foreach(array_slice($popular,0,5) as $post){
?>
Menampilkan jumlah post dalam sebuah kategor:
<?=$category_side['title'];?> (<?=count($this->post()->getPostByCategory($category_side['id_category'], '100', 'DESC', WEB_LANG_ID));?>)
Menampilkan Post per id:
<?php
$table = new PoTable('post');
$Query = $table->findAllLimitByAnd(id_post, id_category, active, '2', 'Y', DESC, '7');
foreach($Query as $tampil){
?>
Mengatasi User tidak bisa login:
Masuk file login.php yang ada difolder po-admin terus cari baris seperti ini
->where('users.level', array('1','2','3'))
Tambahkan level member (4) pada baris tersebut menjadi seperti ini
->where('users.level', array('1','2','3','4'))
Phyoner
Kalau untuk snipet pemanggilan video tetapi menjadi slider video spt slider gambar di theme chingsy gmn bang admin ?