【问题标题】:Access Gantry/Rockettheme template params from a Joomla 2.5 Component从 Joomla 2.5 组件访问 Gantry/Rockettheme 模板参数
【发布时间】:2013-08-24 19:44:41
【问题描述】:

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

有没有办法让我访问 Rockettheme/Gantry 框架参数(从我的组件)以查看用户正在查看的布局。在大多数网站的底部,如果使用移动设备,用户可以通过屏幕底部的桌面/移动按钮更改他们查看的布局。我想访问此设置....并在我的 view.html.php 文件中调整我将显示的布局。

这可能吗?我不知道从哪里开始...

【问题讨论】:

    标签: php joomla2.5


    【解决方案1】:

    如果有人感兴趣,我设法创建了一个解决方案,其中包括龙门框架并访问龙门 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
        //------------------------
    

    所以我不确定这是否是正确或可取的方式,但它很有魅力。

    【讨论】:

      猜你喜欢
      • 2012-07-14
      • 2012-04-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-23
      • 2013-06-28
      • 2013-05-01
      相关资源
      最近更新 更多