Results 1 to 5 of 5

Thread: I need some help on the mobile plugin (css+js include)

  1. #1
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    379
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Unhappy I need some help on the mobile plugin (css+js include)

    Hello

    Im stuck on how to do this, i'm extending plugins but they require js and css. And because a mobile page doesn't include all other features of the full page it seems useless to me to include all the css and js of current active plugins. I got these solutions but they all don't really do what i want:
    I could do a header_include_raw, my current favorite but it'll make a lot of requests for all the mini-css files
    OR:
    I could write my own includeMobileCss /Js function but it's a lot of work and the i need to know what function is use to compress the css
    OR:
    or i have to find a way to clear the css/js file and then add the mobile stuff

    Can anyone help me with a deciding? or maybe have a better solution?
    Bye, and thanks
    Ties
    Last edited by ties; 03-12-2010 at 12:23 PM.
    Up top, down low, to slow! - Documentation
    Theme's Newspaper - Nightlight Plugins Autocomplete 0.3 - Mobile 0.2 - Post Images 0.4 - Votebar 0.1

  2. #2
    Former lead dev Nick's Avatar
    Join Date
    Jun 2009
    Location
    Kakamigahara, Japan
    Posts
    2,869
    Blog Entries
    88
    Thanks
    482
    Thanked 806 Times in 526 Posts

    Default

    Hmmm... let's think. The header_include hook is the one that includes all the css/js files. That hook is in the function called from doIncludes, found in a theme's header.php file:

    PHP Code:
        <!-- Include merged files for all the plugin css and javascript (if any) -->
        <?php $h->doIncludes(); ?>
        <!-- End -->
    Does the Mobile plugin provide it's own theme? If not, how about overriding the user's header.php with your own? You can do that with the theme_index_header hook:

    PHP Code:
    public function theme_index_header($h) {
        
    $h->displayTemplate('mobile_header');
        return 
    true// important to prevent the usual header.php template from being used

    Then you can put whatever you like in your own header template, and users can customize it just like any other template.

    An alternative possibility, though not very efficient, would be to do
    PHP Code:
    $h->clearCache('css_js_cache'false); // false simply prevents the "Cache cleared" message from showing. 
    The best place to do that would be in the header_include_raw hook because it comes after header_include so you can be sure all merged css/js (including your own!) will be cleared.

    To help me understand the problem better, let me ask you this: Do you want CSS and JS from other plugins to be included in a mobile theme always, sometimes or never? I might have some more ideas depending on your answer!

  3. #3
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    379
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    hmm its alot to take but i asked for it
    I want them to be never included
    I'll explain in sort of detail how the plugin works
    step 1 :
    theme_index_top triggered for detection of mobile device (to redirect) / url is already mobile
    then the all-in-one 'template' is triggered (which is basicly a sum of all the mobileHooks
    step 2 :
    the mobileHooks are triggered one by one to fill the page with content

    i dont use any plugin hooks in the theme to prevent content to be W3C mobile incompatible as i dont use the pluginHooks it would make no sense to me to include all the scripts and css so my header currently exists of :
    $h->pluginHook('mobile_hook','mobile',array('mobile_head_start'));
    $h->pluginHook('mobile_hook','mobile',array('mobile_head'));
    $h->pluginHook('mobile_hook','mobile',array('mobile_head_end'));

    the advantage is that i can still add plugin hook to the theme like header_include_raw and doInclude (not really one but you get the point)
    but if i do use a pluginhook it will automatically get scripts so header_include_raw is useless in my eyes
    doIncludes would be a great options if i can remove any items from the list
    so i think im going with te custom function
    before $h->pluginHook('mobile_hook','mobile',array('mobile_head_end')); is triggered i'll add:
    HTML Code:
    <link rel="stylesheet" type="text/css" href=" BASEURL . ?client=mobile&type=css" />
    to get all the independant css files (like mobile_sb_base.css) which can be overriden by a THEME/css/mobile_sb_base.css and compress them with a custom function like this one:
    Code:
     header('Content-type: text/css');
      ob_start("compress");
      function compress($buffer) {
        /* remove comments */
        $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
        /* remove tabs, spaces, newlines, etc. */
        $buffer = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $buffer);
        return $buffer;
      }
    
      /* your css files */
      include('master.css');
      include('typography.css');
      include('grid.css');
      include('print.css');
      include('handheld.css');
    
      ob_end_flush();
    Up top, down low, to slow! - Documentation
    Theme's Newspaper - Nightlight Plugins Autocomplete 0.3 - Mobile 0.2 - Post Images 0.4 - Votebar 0.1

  4. #4
    Theme & Plugin Development ties's Avatar
    Join Date
    Feb 2010
    Location
    Enschede, The Netherlands
    Posts
    379
    Blog Entries
    1
    Thanks
    14
    Thanked 133 Times in 58 Posts

    Default

    there is always
    HTML Code:
    <style type="text/css">
      @import url("import1.css");
      @import url "import2.css";
    </style>
    is a creator wants extra styles
    Up top, down low, to slow! - Documentation
    Theme's Newspaper - Nightlight Plugins Autocomplete 0.3 - Mobile 0.2 - Post Images 0.4 - Votebar 0.1

  5. #5
    Junior Member
    Join Date
    Oct 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Is there a way to change the color of the link on top that says 'Login'... for now its yellow and I'm trying to change the basic colors to fit the full version of the site. I managed to change the color of the main title but I cant find the css for the login link color.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Done] Hotaru ready for iPhone and iPod (or mobile)
    By carlo75 in forum Plugin Suggestion Box
    Replies: 35
    Last Post: 03-15-2010, 03:59 PM
  2. Mobile view
    By sinaisix in forum How-To and Troubleshooting
    Replies: 2
    Last Post: 03-09-2010, 04:26 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •