【问题标题】:OctoberCMS Get Theme Settings data in Api/Web serviceOctoberCMS 在 Api/Web 服务中获取主题设置数据
【发布时间】:2016-11-22 11:52:35
【问题描述】:

我创建了一个运行良好的 OctoberCMS 主题。我有我当前和激活的 theme.yaml 像这样。

theme.yaml

name: 5P Group
description: '5P Group OctoberCMS theme. A client website that contains preconfigured pages for static pages, a blog and client area..'
author: Technobrave
homepage: 'http://technobrave.com/'
code: ''
form:
    fields:
        site_logo:
            label: Site Logo
            comment: The website logo as it should appear on the front-end
            type: fileupload
            mode: image
            imageHeight: 32
            imageWidth: 443

如您所见,我添加了一个 网站徽标 标签,管理员可以通过该标签上传徽标,我会在前面显示它,这很好,因为我可以在前面区域显示徽标像这样。

menu.htm

{% if this.theme.site_logo  %}
<img src="{{ this.theme.site_logo.path }}" width="100%" height="auto"/>
{% else %}
<img src="{{ 'assets/images/logo.png'|theme }}" width="100%" height="auto"/>
{% endif %}

但问题是我也在创建一个 api,我想在那个 api 中做同样的事情。这就是我正在尝试的。

routes.php

    use System\Classes\SettingsManager;

    /* API to get Website Logo Dynamically Starts */

    Route::post('/getWebsiteLogo', function () 
    {
        $settings = Settings::instance();

        print_r($settings);



    });
    /* API to get Website Logo Dynamically Ends */

但我有一个错误说

找不到类“设置”

有人可以指导我或建议我如何完成同样的事情,或者说如何在我的一个 api 中获取动态网站徽标吗?

谢谢

【问题讨论】:

    标签: api octobercms


    【解决方案1】:

    好的,伙计们,感谢您的支持..最终我已经像这样工作了。

    routes.php

    <?php 
    use Cms\Classes\ComponentBase;
    use RainLab\Pages\Classes\Router;
    use Cms\Classes\Theme;
    
    /* API to get Website Logo Dynamically Starts */
    Route::post('/getWebsiteLogo', function () 
    {
        $theme = Theme::getActiveTheme();
        $logo_url = '';
        if($theme->site_logo['attributes']['disk_name'])
        {
            echo $theme->site_logo->path; 
        }
    }
    ?>
    

    感谢您的帮助和支持。高度赞赏。

    【讨论】:

      猜你喜欢
      • 2017-03-29
      • 2016-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多