Implement the dedecms gallery Click image flip Function

Source: Internet
Author: User
Tags image flip

1. To achieve this function, we first need to obtain the current page number and total page number of the image page.
Edit the include/inc_archives_view.php file.
(1) locate function parsedmfields and change it:
Function parsedmfields ($ pageno, $ ismake = 1)
{
$ This-> nowpage = $ pageno;
// Obtain the number of the current page
$ This-> fields ['cpagenum'] = $ this-> nowpage;
If ($ this-> splitpagefield! = ""&&
Isset ($ this-> fields [$ this-> splitpagefield])
{
$ This-> fields [$ this-> splitpagefield] = $ this-> splitfields [$ pageno-1];
}
Note that the following is added: Code Used to obtain the current page number:
$ This-> fields ['cpagenum'] = $ this-> nowpage;
(2) locate the function _ construct constructor and change it:
<? PHP
......
$ This-> totalpage = count ($ this-> splitfields );
}
// Obtain the total number of current pages
$ This-> fields ['totalpage'] = $ this-> totalpage;
$ This-> loadtemplet ();
$ This-> parsetempletsfirst ();
}
Note that the following code is added to obtain the total page number:
$ This-> fields ['totalpage'] = $ this-> totalpage;
2. Use Js in the template to analyze static and dynamic pages and flip pages down
Edit article_image.htm or the final template displayed in your gallery and add the following JS Code:
<Script language = "JavaScript">
VaR npage = {Dede: field name = 'cpagenum '/};
VaR totalpage = {Dede: field name = 'totalpage '/};
VaR filename = "";
VaR curl = location. href;

Function gonextpic (){
Str1 =/\. html/ig;
Str2 =/_/ig;
R = curl. Search (str1 );
R1 = curl. Search (str2 );
If (r> 0 ){
If (npage = 1) filename = curl. substr (0, R );
Else filename = curl. substr (0, R1 );

If (npage = totalpage) {location. href = filename + ". html ";}< br> else {
location. href = filename + "_" + (npage + 1) + ". html ";
}< BR >}else {
If (npage = totalpage) {location. href = "view. PHP? Aid = {Dede: field name = 'id'/} ";}< br> else {
location. href =" view. php? Aid = {Dede: field name = 'id'/} & pageno = "+ (npage + 1 );
}< BR >}< br>
In this JS script, we define a method called gonextpic to switch to the next image.
3. Finally, modify the image output code and call the gonextpic method.
modify include/inc_channel_unit.php
to find "// All list or paging Gallery.
the modification is similar. (You need to modify the code several times ):
$ revalue = "


$ alt
\ r \ n ";
:
$ revalue = "
$ alt
";
the end. have fun!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.