26 2012-11-06 17:27:19

Re: Мобильная версия сайта

обновил этот метод https://github.com/Awilum/monstra-cms/c … 3a7546c7c4 будет в следующий версии монстры возможным получать шаблон из другой темы.

Follow me: Twitter | GitHub | Facebook | Вконтакте

Стань спонсором проекта!

Сайт Awilum

Поделиться

27 2012-11-06 19:39:31

Re: Мобильная версия сайта

Так, что бы не запутаться, а то уже я завис.... Поставил monstra с нуля, делаю следующие действия:
1. Открываю index.php
2. Нахожу этот участок кода (57-58 строки):

        // Load site template
        require(MINIFY . DS . 'theme.' . Site::theme() . '.' . Site::template() . '.template.php');

3. Меняю на вот этот участок кода:

// Load site template
if (Agent::isMobile()) {
 require(MINIFY . DS . 'theme.' . 'mobile' . '.' . Site::template('mobile') . '.template.php');  
} 

4. Открываю www/monstra/engine/site.php
5. Нахожу этот участок кода (194-222 строки):

public static function template() {
            // Get current theme
            $current_theme = Option::get('theme_site_name');           
            // Get template
            $template = call_user_func(ucfirst(Uri::command()).'::template');
            // Check whether is there such a template in the current theme
            // else return default template: index
            // also compress template file :)            
            if (File::exists(THEMES_SITE . DS . $current_theme . DS . $template . '.template.php')) {            
                if ( ! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php') or 
                    filemtime(THEMES_SITE . DS . $current_theme . DS . $template .'.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php')) {
                        $buffer = file_get_contents(THEMES_SITE. DS . $current_theme . DS . $template .'.template.php');
                        $buffer = Minify::html($buffer);
                        file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php', $buffer);
                }
                return 'minify.'.$template;
            } else {
                if ( ! File::exists(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php') or
                    filemtime(THEMES_SITE . DS . $current_theme . DS . 'index.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php')) {
                        $buffer = file_get_contents(THEMES_SITE . DS . $current_theme . DS . 'index.template.php');
                        $buffer = Minify::html($buffer);
                        file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php', $buffer);
                }
                return 'minify.index';
            }        
        }

6. Меняю на вот этот участок кода:

        public static function template($theme = null) {
            // Get current theme
            $current_theme = ($theme == null) ? Option::get('theme_site_name') : $theme ;          
            // Get template
            $template = call_user_func(ucfirst(Uri::command()).'::template');
            // Check whether is there such a template in the current theme
            // else return default template: index
            // also compress template file :)            
            if (File::exists(THEMES_SITE . DS . $current_theme . DS . $template . '.template.php')) {            
                if ( ! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php') or 
                    filemtime(THEMES_SITE . DS . $current_theme . DS . $template .'.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php')) {
                        $buffer = file_get_contents(THEMES_SITE. DS . $current_theme . DS . $template .'.template.php');
                        $buffer = Minify::html($buffer);
                        file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php', $buffer);
                }

7. В www/public/themes/default/
создаю шаблон мобильной версии mobile.template.php

Так всё? Проверьте пожалуйста поточнее, а то уже замучился((((((

Поделиться

28

Re: Мобильная версия сайта

7. В www/public/themes/mobile/
создаете тему mobile

Follow me: Twitter | GitHub | Facebook | Вконтакте

Стань спонсором проекта!

Сайт Awilum

Поделиться

29

Re: Мобильная версия сайта

3. Меняю на вот этот участок кода:

if (Agent::isMobile()) {
     require(MINIFY . DS . 'theme.' . 'mobile' . '.' . Site::template('mobile') . '.template.php');  
} else {
     require(MINIFY . DS . 'theme.' . Site::theme() . '.' . Site::template() . '.template.php');       
} 
Follow me: Twitter | GitHub | Facebook | Вконтакте

Стань спонсором проекта!

Сайт Awilum

Поделиться

30 2012-11-06 21:49:13 (2012-11-06 21:49:58 отредактировано newbie)

Re: Мобильная версия сайта

Awilum, что-то опять косяк в коде в www/monstra/engine/site.php
как только меняю на:

        public static function template($theme = null) {
            // Get current theme
            $current_theme = ($theme == null) ? Option::get('theme_site_name') : $theme ;          
            // Get template
            $template = call_user_func(ucfirst(Uri::command()).'::template');
            // Check whether is there such a template in the current theme
            // else return default template: index
            // also compress template file :)            
            if (File::exists(THEMES_SITE . DS . $current_theme . DS . $template . '.template.php')) {            
                if ( ! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php') or 
                    filemtime(THEMES_SITE . DS . $current_theme . DS . $template .'.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php')) {
                        $buffer = file_get_contents(THEMES_SITE. DS . $current_theme . DS . $template .'.template.php');
                        $buffer = Minify::html($buffer);
                        file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php', $buffer);
                }

Белый лист...

Поделиться

31 2012-11-06 22:10:54

Re: Мобильная версия сайта

>>Белый лист...

http://monstra.org/documentation/environments
http://monstra.org/documentation/error-handling

Follow me: Twitter | GitHub | Facebook | Вконтакте

Стань спонсором проекта!

Сайт Awilum

Поделиться

32 2012-11-07 06:20:02

Re: Мобильная версия сайта

Включил, и...? Ничего не меняется нигде. На экране ничего, в логах ничего

Поделиться

33 2012-11-07 06:32:46

Re: Мобильная версия сайта


в index.php
надеюсь ты понимаешь что для мобилки должна грузится мобильная тема. на компе первый require не сработает.

if (Agent::isMobile()) {
             require(MINIFY . DS . 'theme.' . 'mobile' . '.' . Site::template('mobile') . '.template.php');  
        } else {
             require(MINIFY . DS . 'theme.' . Site::theme() . '.' . Site::template() . '.template.php');       
        } 

результат:

Follow me: Twitter | GitHub | Facebook | Вконтакте

Стань спонсором проекта!

Сайт Awilum

Поделиться

34

Re: Мобильная версия сайта

Сергей, мы друг друга не понимаем наверно. Я когда в site.php вставляю ваш код monstra перестаёт работать. До мобильной версии еще и не дошло. Т.е сразу белый экран. Я проверяю в интернете, а не на локальном сервере;-) Меняю обратно в site.php monstra оживает....

Поделиться

35 2012-11-07 06:55:23

Re: Мобильная версия сайта

подумал я может этот код работает только в моей новой Монстре которая в разработке, так нет. взял и заменил в Monstra 2.0.1

в site.php

        /**
         * Get compressed template
         *
         *  <code> 
         *      echo Site::template();
         *  </code>
         *
         * @param  string $theme Theme name
         * @return mixed
         */
        public static function template($theme = null) {
            // Get specific theme or current theme
            $current_theme = ($theme == null) ? Option::get('theme_site_name') : $theme ;          
            // Get template
            $template = call_user_func(ucfirst(Uri::command()).'::template');
            // Check whether is there such a template in the current theme
            // else return default template: index
            // also compress template file :)            
            if (File::exists(THEMES_SITE . DS . $current_theme . DS . $template . '.template.php')) {            
                if ( ! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php') or 
                    filemtime(THEMES_SITE . DS . $current_theme . DS . $template .'.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php')) {
                        $buffer = file_get_contents(THEMES_SITE. DS . $current_theme . DS . $template .'.template.php');
                        $buffer = Minify::html($buffer);
                        file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php', $buffer);
                }
                return 'minify.'.$template;
            } else {
                if ( ! File::exists(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php') or
                    filemtime(THEMES_SITE . DS . $current_theme . DS . 'index.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php')) {
                        $buffer = file_get_contents(THEMES_SITE . DS . $current_theme . DS . 'index.template.php');
                        $buffer = Minify::html($buffer);
                        file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php', $buffer);
                }
                return 'minify.index';
            }        
        }

работает нормально.

я даже целиком заменил на новый site.php https://github.com/Awilum/monstra-cms/b … e/site.php

отлично работает.

файлы необходимо сохранять в utf-8 без bom

Follow me: Twitter | GitHub | Facebook | Вконтакте

Стань спонсором проекта!

Сайт Awilum

Поделиться

36

Re: Мобильная версия сайта

Awilum пишет:

подумал я может этот код работает только в моей новой Монстре которая в разработке, так нет. взял и заменил в Monstra 2.0.1

в site.php

        /**
         * Get compressed template
         *
         *  <code> 
         *      echo Site::template();
         *  </code>
         *
         * @param  string $theme Theme name
         * @return mixed
         */
        public static function template($theme = null) {
            // Get specific theme or current theme
            $current_theme = ($theme == null) ? Option::get('theme_site_name') : $theme ;          
            // Get template
            $template = call_user_func(ucfirst(Uri::command()).'::template');
            // Check whether is there such a template in the current theme
            // else return default template: index
            // also compress template file :)            
            if (File::exists(THEMES_SITE . DS . $current_theme . DS . $template . '.template.php')) {            
                if ( ! file_exists(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php') or 
                    filemtime(THEMES_SITE . DS . $current_theme . DS . $template .'.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php')) {
                        $buffer = file_get_contents(THEMES_SITE. DS . $current_theme . DS . $template .'.template.php');
                        $buffer = Minify::html($buffer);
                        file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.minify.' . $template . '.template.php', $buffer);
                }
                return 'minify.'.$template;
            } else {
                if ( ! File::exists(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php') or
                    filemtime(THEMES_SITE . DS . $current_theme . DS . 'index.template.php') > filemtime(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php')) {
                        $buffer = file_get_contents(THEMES_SITE . DS . $current_theme . DS . 'index.template.php');
                        $buffer = Minify::html($buffer);
                        file_put_contents(MINIFY . DS . 'theme.' . $current_theme . '.' . 'minify.index.template.php', $buffer);
                }
                return 'minify.index';
            }        
        }

работает нормально.

я даже целиком заменил на новый site.php https://github.com/Awilum/monstra-cms/b … e/site.php

отлично работает.

файлы необходимо сохранять в utf-8 без bom

Заменил на вот этот ваш код - всё заработало.... Захожу с мобильного телефона, выдаёт ошибку типа нет темы (mobile), создайте её. Создаю в папке themes папку mobile и сам мобильный шаблон. Но теперь одно НО... она не загружается мобильным, т.е грузится обычная дефолтная тема. Ставлю в настройках тему mobile, на компе и на телефоне грузится, т.е тема рабочая. Возвращаю обратно на дефолтную тему. И там и там дефолтная тема грузится, на телефоне не заменяется дефолтная тема на мобильную..

Поделиться

37

Re: Мобильная версия сайта

зашел со своего HTC Desire HD http://monstra.org/demo/ и увидел index.template.php загруженный из mobile папки

если с ноута захожу, то вижу index.template.php из default папки.

Follow me: Twitter | GitHub | Facebook | Вконтакте

Стань спонсором проекта!

Сайт Awilum

Поделиться

38

Re: Мобильная версия сайта

Awilum пишет:

зашел со своего HTC Desire HD http://monstra.org/demo/ и увидел index.template.php загруженный из mobile папки

если с ноута захожу, то вижу index.template.php из default папки.

Да, у меня так же работает....((( Может можно эти 2 файла у тебя взять index.php и site.php?)))

Поделиться

39

Re: Мобильная версия сайта

http://rghost.ru/41400138

Follow me: Twitter | GitHub | Facebook | Вконтакте

Стань спонсором проекта!

Сайт Awilum

Поделиться

40 (2012-11-07 13:31:11 отредактировано newbie)

Re: Мобильная версия сайта

Awilum,
Есть маленькое предложение для будущей версии:

Таким образом monstra cms сможет поддерживать как фреймвороковые темы, так и мобильные темы на основе jquery mobile. Правда не знаю, как это выглядит с точки зрения производительности и скорости. На ваше усмотрение.

Поделиться

41 2014-09-23 12:02:20

Re: Мобильная версия сайта

Надеюсь ветка все еще работает.
Как реализовать поддержку мобильной версии сайта? Все попытки внедрить вышеописанное предложение безуспешны sad
Я уже реализовал шаблон мобильной версии:
/theme/mobile
Есть основной шаблон:
/theme/lantana
Как выводить мобильную версию? Никак не получается.

Поделиться

42

Re: Мобильная версия сайта

Нашел предложение, выводить второй сайт мобильной версии, но этот метод мне совсем не нравится:

if (Agent::isMobile()) redirect('http://m.site.ru'

Это наполнение второго сайта, не совсем интересно.

Поделиться