织梦CMS能建小程序,其创建小程序的方法是:1、给dedecms做一个API数据接口输出JSON格式数据;2、通过php系统提供的系统函数“json_encode()”转换json编码,然后在小程序里面写好页面对接数据;3、在小程序里面写好页面代码,然后对接请求的接口数据进去即可渲染成想要样式和功能。
本教程操作环境:Windows10系统、DedeCMS 5.7版、DELL G3电脑
织梦CMS能建小程序吗?
能。
织梦(dedecms)百度智能小程序制作的方法
很多站长都在使用知名的织梦DEDECMS这个程序做网站,特别是一些小白站长,网站制作简单复制粘贴或随便找个模板就可以,但是百度小程序很多人都不会,因为它都是数据对接的,
我们要做的百度智能小程序并不是那种webview载入一个H5网页嵌套那种,那种会影响用户使用的功能体验,百度官方也很难审核通过的。
我们要做的是小程序内不存在H5页面嵌套,而是小程序每个页面都是通过接口数据对接的,如下图每个页面都是通过数据对接的:
百度织梦小程序
制作百度小程序,首先需要给dedecms做一个API数据接口输出JSON格式数据,我们用浏览器打开请求接口地址如下图:
数据接口请求
织梦系统给我们提供了一个json类,在include/json.class.php文件里面,也就是是说,我们在对php文件转换json编码
百度智能小程序制作的方法流程如下:
直接用php系统给我们提供的系统函数,json_encode(),我们如下面写上函数
$dsql->SetQuery("Select arc.id,arc.title,arc.litpic,t.sitepath,arc.description,arc.pubdate,arc.senddate,arc.source,addon.body From `#@__archives` arc addon.aid=arc.id left join `#@__arctype`t on arc.typeid=t.id where channel=1 And FIND_IN_SET('$fid',flag) order by id desc limit 0,5");$dsql->Execute('me');while ($row = $dsql->GetArray('me')) { if (preg_match('/(http:\/\/)|(https:\/\/)/i', $row['litpic'])) { $row['pic'] = $row['litpic']; unset($row['litpic']); }else { $row['pic'] = "https://".$row['litpic']; unset($row['litpic']); } $row['newsId'] = $row['id']; unset($row['id']); $row['description'] = $row['description']; $row['sitepath'] = str_replace('{cmspath}','',$row['sitepath']); $row['updateTime'] = strftime("%Y-%m-%d %H:%M:%S",$row['pubdate']); unset($row['pubdate']); $row['time'] = strftime("%Y/%m-%d/",$row['senddate']); unset($row['senddate']); $row['media'] = $row['source']; unset($row['source']); $row['content'] = $row['body']; //只允许使用 <p> <img src="/static/imghwm/default1.png" data-src="\1" class="lazy" alt="Can DreamWeaver CMS build mini programs?" > <ul> <li> $row['content'] = preg_replace('/<img src="/static/imghwm/default1.png" data-src="\1" class="lazy" .+?src=\"(.+?)\".+? alt="Can DreamWeaver CMS build mini programs?" >/','<img src="/static/imghwm/default1.png" data-src="\1" class="lazy" alt="Can DreamWeaver CMS build mini programs?" >',$row['content']); // $row['content'] = str_replace("/uploads/","/uploads/",$row['content']); unset($row['body']); $reval[] = $row; echo json_encode(array('list'=>$reval));
就这样我们就可以输出栏目列表的数据了,然后我们小程序里面写好页面对接数据。
如下图我们在小程序里面写好页面代码,然后对接请求的接口数据进去就可以渲染成我们想要样式和功能了。
百度小程序列表页面制作
百度小程序我们做的列表页面渲染出来的样式就如下图了.
百度小程序列表页
这样百度小程序我们就制作完成了,制作好调试好后,就可以提交百度小程序平台发布了。
推荐学习:dedecms教程
The above is the detailed content of Can DreamWeaver CMS build mini programs?. 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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

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

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

SublimeText3 Chinese version
Chinese version, very easy to use