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="/static/imghwm/default1.png" data-src="[field:imgsrc/]" class="lazy" style="max-width:90%" style="max-width:90%" / alt="How to add automatic numbers to pictures in the album in DEDECMS" ></span> {/dede:productimagelist}
If there are 3 pictures, the result is:
The code is as follows:
<span id="0"><img src="/static/imghwm/default1.png" data-src="1.jpg" class="lazy" style="max-width:90%" style="max-width:90%" / alt="How to add automatic numbers to pictures in the album in DEDECMS" ></span> <span id="1"><img src="/static/imghwm/default1.png" data-src="2.jpg" class="lazy" style="max-width:90%" style="max-width:90%" / alt="How to add automatic numbers to pictures in the album in DEDECMS" ></span> <span id="2"><img src="/static/imghwm/default1.png" data-src="3.jpg" class="lazy" style="max-width:90%" style="max-width:90%" / alt="How to add automatic numbers to pictures in the album in DEDECMS" ></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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Atom editor mac version download
The most popular open source editor

SublimeText3 Linux new version
SublimeText3 Linux latest version

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),