IE-only stylesheets

11 views
Skip to first unread message

Daniel Lohse

unread,
Nov 30, 2009, 11:21:05 AM11/30/09
to diem-...@googlegroups.com
So, I have the layout thing working.

But there's one problem: my IE-only stylesheet is not wrapped in conditional comments, something that works with symfony > 1.2

I have this in my view.yml in apps/front/config/view.yml:

default:
http_metas:
content-type: text/html

metas:

stylesheets:
- layout
- main
- markdown
- navigation
- styles
-
print: { media: print }
-
ie_custom:
condition: lte IE 7

javascripts:
- front

has_layout: true
layout: layout

This works because I deployed it a few days ago in the non-CMS version of the website.

Any thoughts?

ornicar

unread,
Dec 1, 2009, 6:28:47 AM12/1/09
to diem-users
OK, there is another way to do it with Diem.

To include an ie special stylesheet, create a web/theme/css/browser
directory. The inside it, create the files you need :
ie6.css
ie7.css
ie8.css

They will be included automatically with conditionnal comments.

*as a sidenote* : I realize that Diem has too many special way to do
things. In this example, as all stylesheets are compressed and sent
into one file to the browser, I had to find another way to include
browser specific stylesheets. But nevertheless, it should not require
the symfony dev to use another way to do it. We should keep the
symfony view.yml syntax, and the Diem features. #TODO

Daniel Lohse

unread,
Dec 1, 2009, 6:55:21 AM12/1/09
to diem-...@googlegroups.com
Well, there are always other ways to do things and this is not so bad.

In my own projects I have to *manually* compress all the stylesheets so I prefer Diem doing that automatically for me.

What I don't get is the following. When I do it the symfony way, I can do: "lte IE 7". How do I do that with your way? ;-)
For now I duplicated the file and have ie6.css and ie7.css but it's not that elegant.

Daniel

Daniel Lohse

unread,
Dec 1, 2009, 7:08:21 AM12/1/09
to diem-...@googlegroups.com
Hmm, I don't seem to get it to work. I created the "browser" directory inside web/theme/css/
and moved the ie6.css & ie7.css into it.

What then? I cleared the cache, rebuilt the project, no luck. I even added ie6 and ie7 into the view.yml (without any parameters).
They don't show up in the source code. :(


Daniel

On 2009-12-01, at 1/December, 12:28 PM, ornicar wrote:

thibault

unread,
Dec 1, 2009, 7:23:24 AM12/1/09
to diem-...@googlegroups.com
Sorry, I were wrong. It's

msie6.css
msie7.css
msie8.css

( you can see it in dmFrontLayoutHelper.php l.31 )

2009/12/1 Daniel Lohse <annism...@googlemail.com>:

Daniel Lohse

unread,
Dec 1, 2009, 7:33:19 AM12/1/09
to diem-...@googlegroups.com
Okay, it's working now. :) Thanks!

But still, this will never be possible with the current system: <!--[if lte IE 7]>...<![endif]-->

:(

Daniel

thibault

unread,
Dec 1, 2009, 7:46:11 AM12/1/09
to diem-...@googlegroups.com
For now Diem doesn't handle this case. It probably will later.

But what Diem does not yet, you can do yourself right now.

You can replace the front layout_helper service and override its
renderBrowserStylesheets method.

In apps/front/config/dm/services.yml :

parameters:
layout_helper.class: myFrontLayoutHelper // change the
service class name

Then create apps/front/lib/myFrontLayoutHelper.php :

class myFrontLayoutHelper extends dmFrontLayoutHelper
{

public function renderBrowserStylesheets()
{
$html = parent::renderBrowserStylesheets();

// add your own stuff to $html;

return $html;
}

It's just an example to show how to extend Diem. But I agree this
feature may be integrated to Diem core.

2009/12/1 Daniel Lohse <annism...@googlemail.com>:

Daniel Lohse

unread,
Dec 1, 2009, 7:54:11 AM12/1/09
to diem-...@googlegroups.com
Ha, dependency injection hard at work there! Thanks! I really have to get used to this (new) power. :)

Daniel

ornicar

unread,
Dec 1, 2009, 1:32:33 PM12/1/09
to diem-users
Now ( latest svn version ) the symfony way to include browser specific
stylesheet works with Diem.

I removed automatic inclusion of the stylesheets in the browser dir.

On Dec 1, 1:54 pm, Daniel Lohse <annismcken...@googlemail.com> wrote:
> Ha, dependency injection hard at work there! Thanks! I really have to get used to this (new) power. :)
>
> Daniel
>
> On 2009-12-01, at 1/December, 1:46 PM, thibault wrote:
>
> > For now Diem doesn't handle this case. It probably will later.
>
> > But what Diem does not yet, you can do yourself right now.
>
> > You can replace the front layout_helper service and override its
> > renderBrowserStylesheets method.
>
> > In apps/front/config/dm/services.yml :
>
> > parameters:
> >  layout_helper.class:        myFrontLayoutHelper // change the
> > service class name
>
> > Then create apps/front/lib/myFrontLayoutHelper.php :
>
> > class myFrontLayoutHelper extends dmFrontLayoutHelper
> > {
>
> >  public function renderBrowserStylesheets()
> >  {
> >    $html = parent::renderBrowserStylesheets();
>
> >    // add your own stuff to $html;
>
> >    return $html;
> >  }
>
> > It's just an example to show how to extend Diem. But I agree this
> > feature may be integrated to Diem core.
>
> > 2009/12/1 Daniel Lohse <annismcken...@googlemail.com>:
> >> Okay, it's working now. :) Thanks!
>
> >> But still, this will never be possible with the current system: <!--[if lte IE 7]>...<![endif]-->
>
> >> :(
>
> >> Daniel
>
> >> On 2009-12-01, at 1/December, 1:23 PM, thibault wrote:
>
> >>> Sorry, I were wrong. It's
>
> >>> msie6.css
> >>> msie7.css
> >>> msie8.css
>
> >>> ( you can see it in dmFrontLayoutHelper.php l.31 )
>
> >>> 2009/12/1 Daniel Lohse <annismcken...@googlemail.com>:
Reply all
Reply to author
Forward
0 new messages