繁体   English   中英

从Joomla 2.5组件访问Gantry / Rockettheme模板参数

[英]Access Gantry/Rockettheme template params from a Joomla 2.5 Component

G'Day,我有一个为Joomla 2.5设计的自定义组件。 目前,我正在使用Rockettheme模板。 我遇到的问题是我在组件中的设计没有响应,因此在iphone / android等上看起来很糟糕。

我是否可以通过我的组件来访问rockettheme /龙门框架参数,以查看用户正在查看的布局。 在大多数站点的底部,如果通过屏幕底部的桌面/移动按钮使用移动设备,则用户可以更改其查看的布局。 我想访问此设置...。然后在我的view.html.php文件中调整要显示的布局。

这可能吗? 我丝毫没有从哪里开始的线索...

如果有人感兴趣,我设法创建了一个包括龙门框架的解决方案,并访问龙门cookie来确定用户正在查看的布局。 (正常的default.php文件或default_phone.php)

我们开始:在您的view.html.php文件中:

    //-----------------
    // Add the Gantry framework and access the iphone switcher values!
    //-----------------
    $gantry_path = JPATH_SITE . '/libraries/gantry/gantry.php';
    if (file_exists($gantry_path))
    {
        require_once($gantry_path);
    }
    else
    {
        echo "error " . JText::_('Unable to find Gantry library.  Please make sure you have it installed.');
        die;
    }

    global $gantry;

    $prefix = 'viewswitcher-'.$gantry->get('template_prefix');
    $cookiename = $prefix.$gantry->browser->platform.'-switcher';
    $cookie = JRequest::getVar($cookiename, false, 'COOKIE', 'STRING'); 

    if($cookie == true)
    {
        //User is viewing from iphone mode
        $tpl = 'phone'; // this will call the layout file named: default_phone.php (It MUST be called default_xxx.php)
    }
    else{
        //User is viewing from desktop - Do nothing! - view.html.php will call the normal default.php layout
    }
    //------------------------
    // End Gantry Framework
    //------------------------

因此,我不确定这是否是正确或建议的方法,但确实很有魅力。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM