Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
702 views
in Technique[技术] by (71.8m points)

php - Symfony 3.4 LiipThemeBundle loads desktop template for phone

I have installed Liip Theme Bundle on my Symfony 3.4.47 project. Its directory structure has the mobile template that should be loaded for mobile devices (Resources/themes/phone/) and the Symfony default desktop version (Resources/views/).

The said directory structure worked for Symfony 2.1 but it does not work properly in Symfony 3.4. However I have figured out that it recognizes which theme to load depending on the display size but it displays the default desktop version (Resources/views/) for both desktop and mobile displays instead of showing (Resources/themes/phone/) for mobile explicitly. How can I fix this issue? Shown below is the directory structure and content in files related to Liip Theme Bundle installation.

Symfony directory structure

src/
    AppBundle/
        Resources/
            views/
                Home/
                    index.html.twig
                layout.html.twig
            themes/
                phone/
                    Home/
                       index.html.twig
                    layout.html.twig

app/AppKernel.php

public function registerBundles() {
    $bundles = [
        ...
        new LiipThemeBundleLiipThemeBundle(),
        ...
    ];

app/config/config.yml

liip_theme:
    themes: ['web', 'phone']
    autodetect_theme: true
    load_controllers: true
    cookie:
        name: LoadEVTheme
        lifetime: 3600
        path: /
        domain: ~
        secure: false
        http_only: false
    

Resources/views/Home/index.html.twig and Resources/views/themes/phone/Home/index.html.twig

{% extends '@App//layout.html.twig' %}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...