Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

order in cgi function output ?

by lepetitalbert (Abbot)
on Jan 31, 2008 at 14:08 UTC ( [id://665354]=perlquestion: print w/replies, xml ) Need Help??

lepetitalbert has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I have :

print start_html({ -title => "title" , -style=>{-src=>[ "/$common_css" , "/$css" , "/$common_cal_css" , " +/$cal_css" ]} , -head => "<!--[if IE]><link href=\"/ie.css\" rel=\"stylesheet\" ty +pe=\"text/css\"><![endif]-->" } );

output :

<head> <title>title</title> <!--[if IE]><link href="/ie.css" rel="stylesheet" type="text/css"><![e +ndif]--> <link rel="stylesheet" type="text/css" href="/common.css" /> <link rel="stylesheet" type="text/css" href="/1680x1050-css.css" /> <link rel="stylesheet" type="text/css" href="/common_cal.css" /> <link rel="stylesheet" type="text/css" href="/1024x768-cal.css" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head>

I need to have the "if IE" after my other css.

Can I do that ?

Thanks

Havee a nice day.

"There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates

Replies are listed 'Best First'.
Re: order in cgi function output ?
by moritz (Cardinal) on Jan 31, 2008 at 14:52 UTC

      Actually, if you look at the source for CGI::start_html(), you'll see that an ordered hash would make no difference.

      for( start_html({ -title => "title", -style => { -src => [ "/$common_css", "/$css", "/$common_cal_css", "/$cal_css", "/ie.css", ], }, }) ) { s{(<[^>]+/ie\.css[^>]+>)}{<!--[if IE]>$1<![endif]-->}; print; }

      - tye        

Re: order in cgi function output ?
by ysth (Canon) on Jan 31, 2008 at 18:07 UTC
    Don't be afraid to just print the string you actually want, perhaps with a comment giving the CGI snippet that created it and saying how you modified it.
Re: order in cgi function output ?
by ruzam (Curate) on Jan 31, 2008 at 19:23 UTC
    Try skipping the '-head' all together. You can include code in the -style section with the -code key. According to the CGI documentation "Style definitions in -code override similarly-named ones in -src", and hence come after the -src links by default.
    print start_html({ -title => "title" , -style=>{ -src=>[ "/$common_css" , "/$css" , "/$common_cal_css" , "/$cal_css +" ], -code => '<!--[if IE]><link href="/ie.css" rel="stylesheet" type=" +text/css"><![endif]-->' }, });
    This results in
    <head> <title>title</title> <link rel="stylesheet" type="text/css" href="/common.css" /> <link rel="stylesheet" type="text/css" href="/1680x1050-css.css" /> <link rel="stylesheet" type="text/css" href="/common_cal.css" /> <link rel="stylesheet" type="text/css" href="/1024x768-cal.css" /> <style type="text/css"> <!--/* <![CDATA[ */ <!--[if IE]><link href="/ie.css" rel="stylesheet" type="text/css"><![e +ndif]--> /* ]]> */--> </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head>

      Hello dear Monks,

      I first went back to my print qq, but ruzam's solution is really nicer :)

      Thank you all.

      Have a nice day.

      "There is only one good, namely knowledge, and only one evil, namely ignorance." Socrates

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://665354]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-03-19 07:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found