Removing Default Stylesheets from a custom theme

Discussion in 'aMember Pro v.4' started by chriswallace, Mar 15, 2012.

  1. chriswallace

    chriswallace New Member

    Joined:
    Feb 6, 2010
    Messages:
    16
    What's an upgrade safe way of removing a theme's default stylesheets? (reset & amember)

    I see how they added a stylesheet from the sample theme example, but they don't show a way of removing ones that are being loaded into the theme via the <?php $this->printLayoutHead() ?>

    Sorry if this is a silly question, I just don't think I should muck around in
    library/Am/View.php ​
    which is where the printLayoutHead() function lives.

    Anyone have experience with this?
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,274
    Create empty files in /amember/application/default/themes/YOURTHEMENAME/public/css/amember.css and reset.css
  3. chriswallace

    chriswallace New Member

    Joined:
    Feb 6, 2010
    Messages:
    16
    I'm sorry but that doesn't really solve the problem. There will still be two useless http requests in each of the template files.
  4. alex

    alex Administrator Staff Member

    Joined:
    Jan 24, 2004
    Messages:
    6,020
    These responses will be cached by client browser, and will not be repeated for each request.
    To remove these CSS completely, you have to :
    - either edit Am/View.php : printLayoutHead() function (not recommended)
    - setup a hook for AFTER_RENDER event:
    application/configs/site.php
    PHP:
    <?php
    Am_Di
    ::getInstance()->hook->add(Am_Event::AFTER_RENDER'myAfterRender');
    function 
    myAfterRender(Am_Event_AfterRender $event)
    {
          
    $event->replace('|<style.+?public/css/amember.css">|',''); // regexp is not tested (!)
    }
  5. chriswallace

    chriswallace New Member

    Joined:
    Feb 6, 2010
    Messages:
    16
    Thank you, that after_render hook sounds like what I was looking for!
  6. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    1,670
    Just for reference - correct code to remove amember.css from layout is:
    PHP:
    Am_Di::getInstance()->hook->add(Am_Event::AFTER_RENDER,  function (Am_Event_AfterRender $event) {
        
    $event->replace('|<link.+?public/css/amember.css".*?>|','');
    });

Share This Page