Home > Backend Development > PHP Tutorial > Discuz! Tutorial: How to modify theme views through a simple php file?

Discuz! Tutorial: How to modify theme views through a simple php file?

jacklove
Release: 2023-03-27 13:42:02
Original
1984 people have browsed it

This article explains how to modify the theme views through a simple php file.

Many webmasters need to be able to modify the page views of a theme under certain specific needs, but they don’t know how to do it. This article introduces a method of modifying the page views of a theme through a simple file;

Create a file, such as: threadviews.php

Write the following code

<!--?php
define(&#39;APPTYPEID&#39;, 127); 
define(&#39;CURSCRIPT&#39;, &#39;threadviews&#39;); 
require &#39;./source/class/class_core.php&#39;; 
$discuz = & discuz_core::instance();$discuz--->cachelist = $cachelist;$discuz->init();
Copy after login

//The following is the post tid to be modified, change it to the one you want to modify

$tid=123;
Copy after login

//The following is the target pageviews to be modified

$views=999; 
DB::update(&#39;forum_thread&#39;,array(&#39;views&#39;=>$views),array(&#39;tid&#39;=>$tid));
C::t(&#39;forum_thread&#39;)->clear_cache($tid);
echo &#39;ok&#39;;
?>
Copy after login

Then upload threadtime.php to the root directory of your forum (i.e. the same as forum.php, home.php Directory)!

Open the URL in the browser: http://your domain name/threadviews.php

When you see the page outputs ok, the modification is successful!

The above code can modify the page views of one topic at a time. If you need to modify it in batches, you can use a plug-in. The Discuz! Application Center has a plug-in that can modify the page views in batches.

This article introduces how to modify the theme views through a simple PHP file. For more related content, please pay attention to the PHP Chinese website.

Related recommendations:

php method of obtaining time

php object-oriented selection sorting example explanation

PHP Tips: Cleverly use json_encode() to assign values ​​to js arrays

The above is the detailed content of Discuz! Tutorial: How to modify theme views through a simple php file?. 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