Please upgrade here. These earlier versions are no longer being updated and have security issues.

How do i apply the mobile theme to tab?

Hi

Is it possible to apply the mobile themes to tablet?

«1

Comments

  • hgtonighthgtonight ∞ · New Moderator

    Garden (and by extension Vanilla) uses a general function called IsMobile() to determine if running a mobile device or not. The theme manager chooses the theme based on the return value.

    Override the IsMobile() function by declaring your custom version in your /conf/bootstrap.before.php file.

    For reference, the default IsMobile() function is defined in /library/core/functions.general.php around line 1258.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    whu606UnderDogmahesh
  • hbfhbf wiki guy? MVP

    @hgtonight said:
    Garden (and by extension Vanilla) uses a general function called IsMobile() to determine if running a mobile device or not. The theme manager chooses the theme based on the return value.

    Override the IsMobile() function by declaring your custom version in your /conf/bootstrap.before.php file.

    For reference, the default IsMobile() function is defined in /library/core/functions.general.php around line 1258.

    now, how in the hell did you know that?

    UnderDoghgtonight
  • IsMobile() function returns the following somewhere.
    return $IsMobile;

    Where does it return the value?
    Where can i find the mobile vs desktop theme changer code?

    I don't find bootstrap.before.php in conf folder

  • peregrineperegrine MVP
    edited November 2013

    I don't find bootstrap.before.php in conf folder

    create it.

    I think they have already answered your other questions.

    you can also search for bootstrap on the forum, i know I've answered this question before and so have other people.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Right now, It is going to be mobile or desktop. How do i create new theme for tab? I might need more theme for different device.

    How do i do that?

  • return C(!IsMobile() ? 'Garden.Theme' : 'Garden.MobileTheme', 'default');
    return C(!IsMobile() ? 'Garden.Theme' : !isTab() ? 'Garden.MobileTheme' : 'Garden.TabletTheme', 'default');

    Where is Garden.Theme and MobileTheme defined?
    If I changed that line in functions.general.php and class.thememanager.php, how will it affect the plugins?

  • peregrineperegrine MVP
    edited November 2013

    Right now, It is going to be mobile or desktop. How do i create new theme for tab? I might need more theme for different device.

    see this as reference....

    http://vanillaforums.org/discussion/comment/171195/#Comment_171195

    I am sorry - I have a low patience level. But perhaps others can help you. So my apologies.

    How do i do that?

    first off - does the word "thank you" exist in your language.
    you start multiple threads, but don't pursue them and answer them
    read the documentation.
    you are asking people questions, how do I, and then they give you advice and then you want them to write the apps for you. I suggest you hire a developer.

    you also need to use the "search" box more effectively, it will provide you lots of information.

    and please re-read these....

    http://vanillaforums.org/discussion/23130/forum-post-ettikett-etiquette

    http://vanillaforums.org/discussion/17954/food-for-thought-forum-etiquette

    http://vanillaforums.org/discussion/25115/how-to-how-can-a-new-user-better-help-the-community-when-asking-a-question

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • @mahesh said:
    return C(!IsMobile() ? 'Garden.Theme' : 'Garden.MobileTheme', 'default');
    return C(!IsMobile() ? 'Garden.Theme' : !isTab() ? 'Garden.MobileTheme' : 'Garden.TabletTheme', 'default');

    Where is Garden.Theme and MobileTheme defined?
    If I changed that line in functions.general.php and class.thememanager.php, how will it affect the plugins?

    you were already given the suggested way to do things, and now you want to modify the core.
    which is not a good idea. we are going in circles.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • @peregrine said:

    you start multiple threads, but don't pursue them and answer them read the documentation

    Multiple threads for same topic?
    When did i ask others to write plugin for me?
    There are different threads with different questions. I havent got time to workout on them. So, they are still open.

    Since you asked, I will add the word 'Thank You' in every my reply :)

  • peregrineperegrine MVP
    edited November 2013

    good luck. and I hope you find the time to work on things and i hope you find the search box valuable and that you find time to read the etiquette threads. I won't bother you any more.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • If my previous reply was rude, I am extremely sorry. I didnt mean to be like that. I can see from your reply that you took that that way. English is not my mother tongue.

    You have given me links for old threads.
    Actually where can i read about bootstrap.before.php?
    I can see that creating new theme for tab is possible without touching the core from your reply.

    PS: I used to close thread and i used to say thanks in all my threads even before they were answered. Here, In vanilla forums, everything goes wrongly. If i open old thread, i am told that i opened old thread. If i create new topic for existing thread, i am told that i am making duplicates. That is the reason i asked just questions without adding any other extra word.

    Apart from everything, Thanks for all your help.

    Shadowdare
  • simply put bootstrap.before.php and bootstrap.after.php

    that get called before and after the bootstrap program is called

    all you have to do is create a file with one line it.

    <?php if (!defined('APPLICATION')) exit();
    

    if a function in vanilla core has a line that starts with

     if (!function_exists(
    

    it can be overrriden via the booststrap technique specified.

    it no simpler or harder than that.

    As to side affect of doing things, you can't expect to have an answer of the side affect of you changing a function. no one knows what your change will be. "You" and you alone need to experiment and test the changes you make.

    geez - most of your answers can be found by searching. you can still read an old thread without resurrecting it.

    http://vanillaforums.org/search?adv=&search=bootstrap.before

    The documentation is on the the documentation link, and the wiki, if its not there you may search the forum for information. I'm just saying you don't seem to be reading the answers supplied and start off on new tangents.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • peregrineperegrine MVP
    edited November 2013

    also take a gander in the developer threads.

    http://vanillaforums.org/discussion/22107/can-any-function-be-overridden-via-bootstrap

    they may prove "insightful" to you.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • hgtonighthgtonight ∞ · New Moderator

    @mahesh said:
    return C(!IsMobile() ? 'Garden.Theme' : 'Garden.MobileTheme', 'default');
    return C(!IsMobile() ? 'Garden.Theme' : !isTab() ? 'Garden.MobileTheme' : 'Garden.TabletTheme', 'default');

    Where is Garden.Theme and MobileTheme defined?

    Any string passed through the C() function is looking for a configuration option of that name. It splits . into sub arrays. In your example, C('Garden.MobileTheme', 'default'); will return the value set in your /conf/config.php for $Configuration['Garden']['MobileTheme'] = 'mobile';

    If the config method can't find anything, it will return false or whatever you pass in as the second argument.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    peregrine
  • garden theme is in config.php

    $Configuration['Themes'] = "yourgardenttheme";
    

    mobile theme is

    $Configuration['Garden']['MobileTheme'] = "yourmobiletheme";
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • maheshmahesh New
    edited November 2013

    Yes, I understand that.
    I can even successfully override the IsMobile function in bootstrap.before.php

    I can change it to theme or mobile in bootstrap.before.php.
    I have create a new theme tab in the themes folder.

    I can detect whether it is mobile or tab or computer in my function.
    How do i apply the tab theme to tab viewers?

    Thank you!

  • peregrineperegrine MVP
    edited November 2013

    I extend "you are welcome" from the community.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • Honestly, I don't like those buttons.
    Moreover, This thread is unsolved!

    Yes, I started with applying the mobile theme to tab.
    @hgtonight told me the solution for that.

    As you can see, I changed my mind, I want to try applying new theme on tab.
    But not going to use it so early anyway. Just wanted to try that. I want to know how deep i can extend Vanilla.

  • hgtonighthgtonight ∞ · New Moderator

    So you want a third option for a theme?

    The theme manager is pluggable, so you can override it via a plugin.

    $PluginInfo['EnableTabletTheme'] = array(
        'Name' => 'Enable Tablet Theme',
        'Description' => 'Enables tablet detection and gives an option to select the mobile and tablet themes.',
        'Version' => '0.1',
        'RequiredApplications' => array('Vanilla' => '2.0.18.8'),
        'Author' => "Zachary Doll",
        'AuthorEmail' => '[email protected]',
        'AuthorUrl' => 'http://www.daklutz.com',
        'License' => 'GPLv3'
    );
    
    class EnableTabletTheme extends Gdn_Plugin {
      public function Gdn_ThemeManager_CurrentTheme_Override() {
        return C(!IsMobile() ? 'Garden.Theme' : 'Garden.MobileTheme', 'default'); return C(!IsMobile() ? 'Garden.Theme' : !$this->isTab() ? 'Garden.MobileTheme' : 'Garden.TabletTheme', 'default');
      }
    
      private function isTab() {
        // Detection in here
      }
    }
    

    Untested, but the theory is sound.

    @mahesh said:
    Honestly, I don't like those buttons.

    We treat positive reactions as acknowledgement of help. Save for donations, reactions keep the regulars going.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    ShadowdareperegrinemaheshUnderDog
  • peregrineperegrine MVP
    edited November 2013

    I like your idea @hgtonight. maybe he will report back after it is tested and post the entire coding that he used.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
«1
Sign In or Register to comment.