The figure shows how DedeCMS calls up the number of images in the gallery:
You can add a helper function. Open/include/helpers/archive. helper. php and add the following code at the bottom:
The code is as follows: |
Copy code |
/** * Obtain the number of images in the gallery. * * @ Param int $ aid gallery id * @ Return array */ If (! Function_exists ('getimgnum ')){ Function Getimgnum ($ aid) { Global $ dsql; $ Imgurls = ''; $ Row = $ dsql-> getone ("Selec t imgurls From 'dede _ addonimages 'where aid =' $ aid '"); If ($ row ){ $ Imgurls = $ row ['imgurls']; } Else { Return 0; } Preg_match_all ("/{dede: img (. *) {/dede: img/isU", $ imgurls, $ wordcount ); $ Count = count ($ wordcount [1]); Return $ count; } } |
Call method in the foreground template:
The code is as follows: |
Copy code |
[Field: id function = "Getimgnum (@ me)"/] |
Code call example:
The code is as follows: |
Copy code |
{Dede: arclist row = '5' type = 'image. 'orderby = click channel = '2 '} <Li> <A href = "[field: arcurl/]" class = "preview"> <br/> [field: title/] </a> <Span class = "intro"> Total: [field: id function = "Getimgnum (@ me)"/] Images </span> </Li> {/Dede: arclist} |
After calling the number of images, of course you can design your own css style to output the number of images in the gallery. You can also implement more functions through js.