当前位置:网站首页>Pbcms adding cyclic digital labels

Pbcms adding cyclic digital labels

2022-06-25 01:24:00 Busy PK ends

background : When I see someone in the group asking me to page the list page , The number opened in the new page is still from 1 Start calculating . At that time, I thought it was very simple , Use it directly php You can assign values to the loop statements of , Then I thought something was wrong , The template file is html Suffix is not .php Format files cannot be used directly php sentence . So I think of the custom labels I made before . Here is a custom tag added .( The purpose is to change the following figure from 11-20 Turn into 1-10)

Front label


 <a href="[list:link]">[list:num][list:title]</a>

among [list:num] It's our new tag

Modified backend :

\apps\home\controller\ParserController.php Class that parses the tag

modify public function parserListLabel($content, $cscode = '') This method

Find this sentence in this method :

 foreach ($data as $value) { //  Cycle by the number of query data 
                    $one_html = $matches[2][$i];
                    for ($j = 0; $j < $count2; $j ++) { //  Cyclic replacement data 
                        $params = $this->parserParam($matches2[2][$j]);
                        $one_html = $this->parserList($matches2[1][$j], $matches2[0][$j], $one_html, $value, $params, $key);
                    }
					
                    $key ++;
                    $out_html .= $one_html;

Then modify the following two sentences :

 foreach ($data as $value) { // Cycle by the number of query data

 $one_html = $this->parserList($matches2[1][$j], $matches2[0][$j], $one_html, $value, $params, $key);

It is amended as follows

foreach ($data as $jb=>$value) { // Cycle by the number of query data

$one_html = $this->parserList($matches2[1][$j], $matches2[0][$j], $one_html, $value, $params, $key,$jb+1);

The goal is actually to get the angle of the current cycle

And then modify parserList This method , New pair list:num Parsing

case 'num':
                $content = str_replace($search, $num, $content);
                break;

At the end default: Add the above parsing before . So you can use this normally [list:num] The label

原网站

版权声明
本文为[Busy PK ends]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206242055036567.html