Не нравятся результаты поиска? Попробуйте другой поиск!
DLE FAQ » Все вопросы » Общие вопросы по PHP » {image-1} для статических станиц

{image-1} для статических станиц


     11.01.2014    {image-1} для статических станиц    Общие вопросы по PHP, Хаки    3265

вопрос
Здравствуйте уважаемые мастера,возможно ли как нибудь реализовать тег {image-1} для статических станиц?

Ответил: rocksmart


/engine/modules/static.php

После строки

$tpl->set( '{description}', $static_descr );


Вставить

if (stripos ( $tpl->copy_template, "{image-" ) !== false) {
            $images = array();
            preg_match_all('/(img|src)=("|\')[^"\'>]+/i',$template, $media);
            $data=preg_replace('/(img|src)("|\'|="|=\')(.*)/i',"$3",$media[0]);
    
            foreach($data as $url) {
                $info = pathinfo($url);
                if (isset($info['extension'])) {
                    if ($info['filename'] == "spoiler-plus" OR $info['filename'] == "spoiler-plus" ) continue;
                    $info['extension'] = strtolower($info['extension']);
                    if (($info['extension'] == 'jpg') || ($info['extension'] == 'jpeg') || ($info['extension'] == 'gif') || ($info['extension'] == 'png')) array_push($images, $url);
                }
            }
    
            if ( count($images) ) {
                $i=0;
                foreach($images as $url) {
                    $i++;
                    $tpl->copy_template = str_replace( '{image-'.$i.'}', $url, $tpl->copy_template );
                    $tpl->copy_template = str_replace( '[image-'.$i.']', "", $tpl->copy_template );
                    $tpl->copy_template = str_replace( '[/image-'.$i.']', "", $tpl->copy_template );
                }
    
            }
    
            $tpl->copy_template = preg_replace( "#\[image-(.+?)\](.+?)\[/image-(.+?)\]#is", "", $tpl->copy_template );
            $tpl->copy_template = preg_replace( "#\\{image-(.+?)\\}#i", "{THEME}/dleimages/no_image.jpg", $tpl->copy_template );
    
        }



Использование в шаблоне static.tpl так же как и в shortstory.tpl

{image-1} {image-2}

Буду рад помощи проекту:
Z550000273552
R355489577439
Чтобы комментировать - войдите или зарегистрируйтесь на сайте

Похожие вопросы

наверх