muban大师 发表于 2018-7-11 12:22:40

织梦DEDECMS文章内容body图文分离调用代码

织梦DEDECMS文章正文调用代码为{dede:field.body/},这样图片和文章都调用出来了。能不能分开调用呢?当然可以啦!调用 代码如下

        内容文字

       
               
                       
                               
                                       
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        1
                                                                               
                                                                                       
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        2
                                                                               
                                                                                        {dede:field.body runphp=yes}
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        3
                                                                               
                                                                                        $string = @me;
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        4
                                                                               
                                                                                        $result = preg_replace("/]+>/i",'',$string);
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        5
                                                                               
                                                                                        @me = $result;
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        6
                                                                               
                                                                                        {/dede:field.body}
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        7
                                                                               
                                                                                       
                                                                       
                                                               
                                                       
                                               
                                       
                               
                       
               
       

       

        内容图片

       
               
                       
                               
                                       
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        01
                                                                               
                                                                                       
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        02
                                                                               
                                                                                        {dede:field.body runphp=yes}
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        03
                                                                               
                                                                                        $string = @me;
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        04
                                                                               
                                                                                        preg_match_all("/[i,,*)s*src=('|")([^'",+)('|")/",$string,$matches);
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        05
                                                                               
                                                                                        $imgsrc_arr = array_unique($matches[3,);
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        06
                                                                               
                                                                                        foreach($imgsrc_arr as $imgsrc)
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        07
                                                                               
                                                                                        {
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        08
                                                                               
                                                                                        $result .= "[*,[i,img" src="$imgsrc"> ";
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        09
                                                                               
                                                                                        }
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        10
                                                                               
                                                                                        @me = $result;
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        11
                                                                               
                                                                                        {/dede:field.body}
                                                                       
                                                               
                                                       
                                               
                                               
                                                       
                                                               
                                                                       
                                                                               
                                                                                        12
页: [1]
查看完整版本: 织梦DEDECMS文章内容body图文分离调用代码