6257rv7 发表于 2024-10-10 03:32:12

fastadmin获取插件的配置参数的办法


    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">fastadmin的<span style="color: black;">每一个</span>插件目录下都有一个config.php文件,存放的是该插件的参数配置。<span style="color: black;">按照</span>官方说明这些config.php中的值在fastadmin内的任何<span style="color: black;">地区</span>都<span style="color: black;">能够</span><span style="color: black;">运用</span>get_addon_config(‘插件文件夹名’)来获取。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">例如</span>说<span style="color: black;">咱们</span>有个插件nkeditor,其config.php文件的内容为:</span></p><span style="color: black;"><span style="color: black;">&lt;?php</span>
      <span style="color: black;">return</span> [
      [
      <span style="color: black;">name</span> =&gt; <span style="color: black;">classname</span>,
      <span style="color: black;">title</span> =&gt; <span style="color: black;">渲染文本框元素</span>,
      <span style="color: black;">type</span> =&gt; <span style="color: black;">string</span>,
      <span style="color: black;">content</span> =&gt; [],
      <span style="color: black;">value</span> =&gt; <span style="color: black;">.editor</span>,
      <span style="color: black;">rule</span> =&gt; <span style="color: black;">required</span>,
      <span style="color: black;">msg</span> =&gt; ,
      <span style="color: black;">tip</span> =&gt; <span style="color: black;">用于对指定的元素渲染,<span style="color: black;">通常</span><span style="color: black;">状况</span>下无需修改</span>,
      <span style="color: black;">ok</span>=&gt; ,<span style="color: black;">extend</span> =&gt; ,
      ],
      [
      <span style="color: black;">name</span> =&gt; <span style="color: black;">theme</span>,
      <span style="color: black;">title</span> =&gt; <span style="color: black;">编辑器主题</span>,
      <span style="color: black;">type</span> =&gt; <span style="color: black;">select</span>,
      <span style="color: black;">content</span> =&gt; [
      <span style="color: black;">default</span> =&gt; <span style="color: black;">经典主题</span>,
      <span style="color: black;">black</span> =&gt; <span style="color: black;">雅黑主题</span>,
      <span style="color: black;">blue</span> =&gt; <span style="color: black;">淡蓝主题</span>,
      <span style="color: black;">grey</span> =&gt; <span style="color: black;">深灰主题</span>,
      <span style="color: black;">primary</span> =&gt; <span style="color: black;">深绿主题</span>,
      ],<span style="color: black;">value</span> =&gt; <span style="color: black;">black</span>,
      <span style="color: black;">rule</span> =&gt; <span style="color: black;">required</span>,
      <span style="color: black;">msg</span> =&gt; ,
      <span style="color: black;">tip</span> =&gt; ,
      <span style="color: black;">ok</span> =&gt; ,
      <span style="color: black;">extend</span> =&gt; ,
      ],
      [
      <span style="color: black;">name</span> =&gt; <span style="color: black;">formulapreviewurl</span>,
      <span style="color: black;">title</span> =&gt; <span style="color: black;">数学公式预览URL</span>,
      <span style="color: black;">type</span> =&gt; <span style="color: black;">string</span>,
      <span style="color: black;">content</span>=&gt; [],<span style="color: black;">value</span> =&gt; <span style="color: black;">https://math.now.sh?from={latex}</span>,
      <span style="color: black;">rule</span> =&gt; ,
      <span style="color: black;">msg</span> =&gt; ,
      <span style="color: black;">tip</span> =&gt; <span style="color: black;">用于渲染数学公式的URL</span>,
      <span style="color: black;">ok</span> =&gt; ,
      <span style="color: black;">extend</span> =&gt; ,
      ],
      [
      <span style="color: black;">name</span> =&gt; <span style="color: black;">wordimageserver</span>,
      <span style="color: black;">title</span> =&gt; <span style="color: black;">启用word<span style="color: black;">照片</span>替换服务器</span>,
      <span style="color: black;">type</span> =&gt; <span style="color: black;">radio</span>,
      <span style="color: black;">content</span> =&gt; [
      <span style="color: black;">1</span> =&gt; <span style="color: black;">是</span>,
      <span style="color: black;">0</span> =&gt; <span style="color: black;">否</span>,
      ],
      <span style="color: black;">value</span> =&gt; <span style="color: black;">0</span>,
      <span style="color: black;">rule</span> =&gt; <span style="color: black;">required</span>,
      <span style="color: black;">msg</span> =&gt; ,
      <span style="color: black;">tip</span> =&gt; <span style="color: black;"><span style="color: black;">倘若</span>启用,请务必先运行word.exe</span>,
      <span style="color: black;">ok</span> =&gt; ,
      <span style="color: black;">extend</span> =&gt; ,
      ],
      [
      <span style="color: black;">name</span> =&gt; <span style="color: black;">attachmentmode_admin</span>,
      <span style="color: black;">title</span> =&gt; <span style="color: black;">管理员附件<span style="color: black;">选取</span>模式</span>,
      <span style="color: black;">type</span> =&gt; <span style="color: black;">select</span>,
      <span style="color: black;">content</span> =&gt; [
      <span style="color: black;">all</span> =&gt; <span style="color: black;">任何管理员均<span style="color: black;">能够</span>查看<span style="color: black;">所有</span>上传的文件</span>,
      <span style="color: black;">auth</span> =&gt; <span style="color: black;">仅<span style="color: black;">能够</span>查看自己及所有子管理员上传的文件</span>,
      <span style="color: black;">personal</span> =&gt; <span style="color: black;">仅<span style="color: black;">能够</span>查看<span style="color: black;">选取</span>自己上传的文件</span>,
      ],
      <span style="color: black;">value</span> =&gt; <span style="color: black;">all</span>,
      <span style="color: black;">rule</span> =&gt; <span style="color: black;">required</span>,
      <span style="color: black;">msg</span> =&gt; ,
      <span style="color: black;">tip</span> =&gt; ,
      <span style="color: black;">ok</span> =&gt; ,
      <span style="color: black;">extend</span> =&gt; ,
      ],
      [
      <span style="color: black;">name</span> =&gt; <span style="color: black;">attachmentmode_index</span>,
      <span style="color: black;">title</span> =&gt; <span style="color: black;">前台附件<span style="color: black;">选取</span>模式</span>,
      <span style="color: black;">type</span> =&gt; <span style="color: black;">select</span>,
      <span style="color: black;">content</span> =&gt; [
      <span style="color: black;">all</span> =&gt; <span style="color: black;">任何会员均可以查看<span style="color: black;">所有</span>上传的文件</span>,
      <span style="color: black;">personal</span> =&gt; <span style="color: black;">仅<span style="color: black;">能够</span>查看<span style="color: black;">选取</span>自己上传的文件</span>,
      ],
      <span style="color: black;">value</span> =&gt; <span style="color: black;">personal</span>,
      <span style="color: black;">rule</span> =&gt; <span style="color: black;">required</span>,
      <span style="color: black;">msg</span> =&gt; ,
      <span style="color: black;">tip</span> =&gt; ,
      <span style="color: black;">ok</span> =&gt; ,
      <span style="color: black;">extend</span> =&gt; ,
      ],
      ];</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">倘若</span><span style="color: black;">咱们</span>要获取它的theme值,<span style="color: black;">能够</span><span style="color: black;">运用</span>如下代码:</span></p><span style="color: black;">$config</span> = get_addon_config(<span style="color: black;">nkeditor</span>);
    <span style="color: black;">echo</span> <span style="color: black;">$config</span>[<span style="color: black;">theme</span>];<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">输出为:</span></p>black




wrjc1hod 发表于 2024-10-18 05:43:09

seo常来的论坛,希望我的网站快点收录。

7wu1wm0 发表于 2024-10-30 16:26:58

我深感你的理解与共鸣,愿对话长流。
页: [1]
查看完整版本: fastadmin获取插件的配置参数的办法