In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail the method of deleting articles and attachments on dedecms. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
How does dedecms delete articles as well as attachments?
The modification method of deleting articles and attachments by dedecms
Dedecms delete articles also delete attachments to modify the method, the use of dedecms friends can refer to.
First add two functions
The code is as follows:
/ * get the body part of the document according to the document id * / function getArcBody ($arcid) {global $dsql; if (empty ($arcid)) return; $body =''; $query = "select arc.*,ch.addtable,ch.fieldset from `dede_ arctiny` as arc left join `dede_ channeltype` as ch on arc.channel=ch.id where arc.id=$arcid"; $row = $dsql- > GetOne ($query); if (empty ($row) return; $addtable = $row ['addtable']; $fieldset = $row [' fieldset'] Include_once (DEDEINC.'./dedetag.class.php'); $dtp = new DedeTagParse (); $dtp- > SetNameSpace ('field',''); $dtp- > LoadSource ($fieldset); if ($dtp- > CTags) {foreach ($dtp- > CTags as $tid= > $tag) {if ($tag- > GetAtt (' type') = = 'htmltext') {$body = $tag- > GetName (); break;} if (! empty ($body)) {$query = "select $body from `$addtable` where aid=$arcid"; $row = $row > dsql- ($dsql-) $body = $row [$body]; return $body;} return;} / * parse the local picture of the document content * / function get_img_from_body ($body) {$result = array (); if (empty ($body)) return $result; preg_match_all ('/\ ssrc= ([\ "|\']) ([^\ 1] *?)\. (gif | jpg | jpeg | png)\ 1 syntax. If (! empty ($res [2])) {foreach ($res [2] as $k = > $v) {$result [] = $v.'.'.$res [3] [$k];}} return $result;}
Post this code after include/common.func.php
Then open the background (assuming the default dede is used as the background) dede/inc/inc_batchup.php file
Add the code on line 22 as follows:
$body = getArcBody ($aid)
Then on line 139, that is,
Return true
Add the following code to the top line
The code is as follows:
If ($body) {$img_arr = get_img_from_body ($body); if (! empty ($img_arr)) {foreach ($img_arr as $v) {$img_file = GetTruePath (). Str_replace ($GLOBALS ['cfg_basehost'],'', $v); if (file_exists ($img_file) & &! is_dir ($img_file) @ unlink ($img_file);}
This makes it possible to delete local images with fields of type "htmltext" when you delete a document.
About dedecms delete articles and also delete attachments on the method to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.