Home > CMS Tutorial > DEDECMS > body text

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

藏色散人
Release: 2019-12-23 10:45:47
Original
2604 people have browsed it

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);
Copy after login

Add a new line after it

$GLOBALS['autoindex'] = 0;
Copy after login

Find:

$revalue .= $ctp->GetResult();
Copy after login

Add a new line after it

$GLOBALS['autoindex']++;
Copy after login

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

[field:global name=autoindex/]
Copy after login

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}
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!