Sabit sayfalar hakkında veri çekebileceğiniz bir eklentidir.Örnek olarak bir sabit sayfanın görüntülenme bilgisini çekmek istiyorsunuz.
Bunun için veritabanında bulunan kolonun/alanın adını belirtmeniz yeterlidir.Aşağıdaki örneklere bakarak daha fazla fikir sahibi olabilirsiniz.
Örnekler :
1) {static name="amacimiz" echo="title"}
2) {static name="amacimiz" echo="template" limit="220" end="..."}
3) {static name="amacimiz" echo="url"}
Karşılıkları :
1) Sabit Sayfa Başlığı
2) Sabit sayfa içeriği, ilk 220 karakteri eğer 220 karakterden uzunsa kesilerek sonuna ... eklenecek
3) Sabit sayfanın url'si : ornek.html
Kurulum :
Aç - index.php
Bul :
$config['http_home_url'] = explode ( "index.php", strtolower ( $_SERVER['PHP_SELF'] ) );// MWS-Custom Static Printer Hack
if (stripos ( $tpl->copy_template, "{static" ) !== false) {
$tpl->copy_template = preg_replace_callback ( "#\\{static(.+?)\\}#i", "custom_static_print", $tpl->copy_template );
}
// MWS-Custom Static Printer Hackfunction custom_print( $matches=array() ) {// MWS Custom Static Printer Hack
function custom_static_print( $matches = array() ) {
global $db, $cat_info, $config, $user_group, $category_id, $_TIME, $lang, $category_id, $PHP_SELF;
if ( !count($matches) ) return "";
$param_str = trim( $matches[1] );
$allowed_echo = array(
"id","name","descr","template","allow_br","allow_template",
"grouplevel","tpl","metadescr","metakeys","views","template_folder",
"date","metatitle","allow_count","sitemap","disable_index"
);
if( preg_match( "#name=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$name = $db->safesql( trim( $match[1] ) );
}
if( preg_match( "#echo=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$echo = $db->safesql( trim( $match[1] ) );
}
if( preg_match( "#limit=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$limit = $db->safesql( trim( $match[1] ) );
}
if( preg_match( "#end=['\"](.+?)['\"]#i", $param_str, $match ) ) {
$end = $db->safesql( trim( $match[1] ) );
}
if ( $echo == "title" ) $echo = "descr";
else if ( $echo == "url" ) $echo = "name";
if ( ! in_array( $echo, $allowed_echo ) ) return "";
$data = $db->super_query("SELECT {$echo} as txt FROM " . PREFIX . "_static WHERE name='{$name}'");
if ( $echo == "name" ) $data['txt'] .= ".html";
if ( ! empty( $limit ) && intval( $limit ) > 0 ) {
$data['txt'] = ( dle_strlen( $data['txt'], $config['charset'] ) > intval( $limit ) ) ? dle_substr( $data['txt'], 0, intval( $limit ), $config['charset'] ) . $end : $data['txt'];
}
return $data['txt'];
}
// MWS Custom Static Printer Hack