Home  >  Article  >  CMS Tutorial  >  How to add automatic numbers to pictures in the album in DEDECMS

How to add automatic numbers to pictures in the album in DEDECMS

藏色散人
藏色散人Original
2019-12-23 10:45:472617browse

How to add automatic numbers to pictures in the album in DEDECMS

DEDECMS How to add automatic numbers to pictures in the album?

When calling the album on the album content page, it is inevitable to use the ID number or something. This tutorial will teach you how to automatically number the images in the album. The code is very simple. Friends who are interested can Let’s understand, I hope it will be helpful to everyone

Recommended study:梦Weavercms

When calling the album on the album content page, if you use certain slides Film effects or jquery plug-ins will inevitably use ID numbers. This tutorial will teach you how to automatically number the pictures in the album. In other words, it is very simple to make the {dede:productimagelist} tag support automatic numbering.

Open the include/taglib/productimagelist.lib.php file and find:

$ctp->LoadSource($innerText);

Add a new line after it

$GLOBALS['autoindex'] = 0;

Find:

$revalue .= $ctp->GetResult();

Add a new line after it

$GLOBALS['autoindex']++;

The changes here are complete, and the next step is to call it on the content page:

[field:global name=autoindex/]

Example:

The code is as follows:

{dede:productimagelist} 
<span id="[field:global name=autoindex/]"><img src="[field:imgsrc/]" width="805" height="523" /></span> 
{/dede:productimagelist}

If there are 3 pictures, the result is:

The code is as follows:

<span id="0"><img src="1.jpg" width="805" height="523" /></span> 
<span id="1"><img src="2.jpg" width="805" height="523" /></span> 
<span id="2"><img src="3.jpg" width="805" height="523" /></span>

The above is the detailed content of How to add automatic numbers to pictures in the album in DEDECMS. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn