惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
大猫的无限游戏
大猫的无限游戏
Engineering at Meta
Engineering at Meta
V
Visual Studio Blog
Martin Fowler
Martin Fowler
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 叶小钗
I
InfoQ
B
Blog RSS Feed
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
Blog — PlanetScale
Blog — PlanetScale
IT之家
IT之家
P
Proofpoint News Feed
WordPress大学
WordPress大学
小众软件
小众软件
B
Blog
MongoDB | Blog
MongoDB | Blog
人人都是产品经理
人人都是产品经理
量子位
Hugging Face - Blog
Hugging Face - Blog
月光博客
月光博客

博客园 - fogwu

豆包加开源工具apache jmeter 生成网站测试报告 windows 服务器 防止黑客利用漏洞上传可执行文件的免费方法 解决js每次刷新都需要实时从服务端获取的方法 powerdesinger 生成数据库结构表图并导出pdf iis 应用程序池通过钉钉机器人进行监控 windows 系统查看文件或文件夹被哪个进程占用并解除的方法 windows server 2022 通过命令行更改远程端口 sqlsever 2008 全文索引的使用 uni-app 开发微信小程序 onLaunch后再执行页面onLoad ASP.NET ”未显示页面,因为请求实体过大“的问题处理 ubutu 安装雷池waf 宝塔 nginx 安装 免费防护墙ModSecurity 模块 laravel postman api 请求, 表单验证不通过,不返回错误信息的json 而是返回302重定向 Windows Server 下 IIS 申请部署 Let's Encrypt 证书实现 免费 HTTPS h5 自适应页面背景图无法自动适应的问题 iis 部署SSL 出现错误的处理方法推荐 think\db\Raw could not be converted to string 错误的处理方式 - fogwu 解决使用js 打印当前页面时会多出一页空白纸张的问题 windiows 显卡安装指定旧版驱动 mysql 5.6 升级到 5.7 教程 winows 下iis+nginx +php 部署 windows cmd 命令中使用grep 查找
mediawiki 调用外站内容方法
fogwu · 2022-12-22 · via 博客园 - fogwu

我使用的skin是 Timeless。在TimelessTemplate.php文件中做了修改

一、加入以下代码,读取远程接口api内容后进行处理

    private  function  handleNews($cateId=0)
    {
        $content=file_get_contents('http://szxw/index.php?s=article&c=search&cateId='.$cateId.'&api_call_function=module_list&appid=1&appsecret=ABDf');
        if(strpos($content,'code'))
        {
          $jscontent=json_decode($content,true);
           $strs='';
            foreach ($jscontent['data'] as $item) {
                $strs.="<li><a target='_blank' href=".$item['url'].">".$item['title']."</a></li>";
            }
            return "<ul>$strs</ul>";
        }
    }

使用以上代码生成了ul内容列表

二、修改方法 getContentBlock 加入了以下内容

protected function getContentBlock() {
        $templateData = $this->getSkin()->getTemplateData();
        $content=$this->get( 'bodytext' );
        if(preg_match('/\$catid(\d+)\$/',$content, $matches ) && $_GET['action']!='edit')
        {
            $content=str_replace($matches[0],$this->handleNews($matches[1]),$content);
        }
...................

    Html::rawElement( 'div', [ 'id' => 'bodyContent' ],
                    $this->getContentSub() .
                    $content.
                    $this->getClear()
                )
            )
        );

        return Html::rawElement( 'div', [ 'id' => 'mw-content' ], $html);
    }

第三步,在创建词条时,加入如下使用

  其中传入参数59为需要处理的目录ID