Issue with extend a view in the page context

For some reason I need to create a stylesheet in PHP format (/view/default/theme/style.php) and load it only on the main page of the site.

I set my custom ('main') page context in index.php and try to extend my custom view like as:

if (elgg_in_context('main')) {
        elgg_extend_view('elgg.css', 'theme/style');
}

Don't work.

But all works with any of these solutions:

if (!elgg_in_context('main')) {
        elgg_extend_view('elgg.css', 'theme/style');
}

or w/o page context:

elgg_extend_view('elgg.css', 'theme/style');

Also, this doesn't work if I try to change the extension and file format:

if (!elgg_in_context('main')) {
        elgg_extend_view('elgg.css', 'theme/style.css');
}

But works if I register/load such file directly:

elgg_register_css('style', elgg_get_simplecache_url('theme/style.css'));

if (elgg_in_context('main')) {
        elgg_load_css('style');
}

But nothing with extending of view :(

Similar with unextend_view:

elgg_extend_view('elgg.css', 'theme/style');

if (elgg_in_context('main')) {
        elgg_unextend_view('elgg.css', 'theme/style');

}

Elgg 2.3.2 / No 3rd party activated plugins

Is it a bug on my side or in core?

  • You can't extend CSS views dynamically with simplecache enabled. That defeats the purpose of simplecache.

  • Thanks. Then I'll rewrite my stylesheet for compatibility with the enabled simplecache

  • A few weeks ago i wrote here in the community on " I quit the core team, here is why," disscusion. "As a plugin developer, I have developed several plugins for fun and most for my clients. Time and Time again, especially when developing a theme plugin for a client or for fun, the elgg engine structure does not make it easier when using custom CSS or "non Elgg CSS". Hence, theme developers have to spend a lot of time going around elgg CSS system and that can be frustrating for a developer who wants things accomplished on a daily basis.I am not complaining but just raising just a few thoughts of mind."The way elgg is designed at the moment is easier for elgg core developers to use custom CSS to achieve a desired theme design. However, for new developers, using custom CSS can be frustrating. As we all know, most clients do not care much about what engine is running their applications online (elgg, wordpress, dolphine, suup, magento, oxwall, and etc), but most clients do care a lot on how their websites look and feel!Is it possible for elgg core developers to look into this issue that has been affecting new clients who might want to use elgg as platform or software of their first choice?Is it possible to offer future elgg theme developers a chance to use a custom simplecache css functions for elgg without spending a lot of time extending or unextending elgg core css?I am commenting using a cellphone, in case my questions are not clear feel free to request for more info or perhaps request for a new discussion on this matter.

  • I don't see how changing or adding custom css could possibly be any easier.  You have options to override the css view, extend a view, or load a custom style sheet.  You can completely unregister the core css view and load your own instead.  Pretty much all use cases are covered.  With caching enabled it's just a matter of remembering that you can't conditionally extend a cached view (this is the case with any cached view, not just css).

  • @Tom Elgg is awesome. I can create everything I need with it. Just need to follow the docs

    Custom CSS and JS isn't a problem for us.

  • the elgg engine structure does not make it easier when using custom CSS or "non Elgg CSS"

    @Tom Create a GitHub ticket with some specific problems you're having and any ideas you have.

    For this particular issue, we need to mention the impact of caching in the Views docs.