blueman378 Posted December 10, 2008 Share Posted December 10, 2008 Hi guys, i was wondering what functions do i need to add a stylesheet into the head section of a page? eg <?php include("somefile.php"); ?> <html (blablabla doctype blablabla> <head> <meta blablabla> <title>blablabla</title> //i want included somefile to add a stylesheet here </head> ... im assuming i will be looking for the </head> tag and replacing it with mystylesheet </head> ? Link to comment https://forums.phpfreaks.com/topic/136338-add-html-into/ Share on other sites More sharing options...
Mchl Posted December 10, 2008 Share Posted December 10, 2008 See the source of this forums and see how it's done <link rel="stylesheet" type="text/css" href="style.css" /> </head> Link to comment https://forums.phpfreaks.com/topic/136338-add-html-into/#findComment-711261 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Author Share Posted December 10, 2008 lol i know that part, i mean it dynamically, so for example i have a script which makes i dunno a table, so i include that script i want that script without the user having to place anything inside the head section i want the script itself to add the css sheet Link to comment https://forums.phpfreaks.com/topic/136338-add-html-into/#findComment-711270 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Author Share Posted December 10, 2008 thats why i said about searching and replacing lol. im assuming to find where t put it i would have to search for the </head> tag and replace it with <link rel="stylesheet" type="text/css" href="style.css" /> </head> Link to comment https://forums.phpfreaks.com/topic/136338-add-html-into/#findComment-711271 Share on other sites More sharing options...
Mchl Posted December 10, 2008 Share Posted December 10, 2008 Or you could treat HTML document as a XML, and use SimpleXML for example to add a child element to head. Dunno I think I'd just put a script there, that would check what css files should be included, and echo proper tags. Link to comment https://forums.phpfreaks.com/topic/136338-add-html-into/#findComment-711278 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Author Share Posted December 10, 2008 yeah i was trying to avoid that lol cause i can do the search and replace easily enough the only hassle would be getting the output html as a string, as far as i know there is no function for this Link to comment https://forums.phpfreaks.com/topic/136338-add-html-into/#findComment-711280 Share on other sites More sharing options...
Mchl Posted December 10, 2008 Share Posted December 10, 2008 What do you mean? You can create all your HTML line-by-line (or tag-by-tag) actually in one single string variable. Then echo all of it at once (setting some headers before if needed) Link to comment https://forums.phpfreaks.com/topic/136338-add-html-into/#findComment-711284 Share on other sites More sharing options...
blueman378 Posted December 10, 2008 Author Share Posted December 10, 2008 basically what im making is a for generator/(validator) one option os for the styling of the form. for that im doing it through css. so a user includesfg.php which includes all required classes ect. the user users: $form1 = new formgenerator; $form1->style = "singleline"; $form1->reset = on; $form1->create("My Form", "showme.php", "post"); $form1->addelement("select", "myname1", "1", "months.php", off); $form1->addelement("select", "myname2", "10", "months.php", on); $form1->addelement("textbox", "mytextbox", 30, 50, off, "alphanum"); $form1->addelement("password", "mypassword", 30, 50, off, "alphanum"); [/code] to create the form. they then place :$form1->generate(); where they want the form to appear. that work fine. but for the styling i need to include a css sheet. a different one depending on the stylew choosen. anyway i dont want the user to have to include fg.php and then have to include eg fgcss.php inside the head section so i dont know what the end html of the page will look like or what the rest of the page entails. so what i really need is a way to capture what php has saved the current page state as and quickly add in my css (this is assuming that php writes the html to itself as it is iterating through the php code) Link to comment https://forums.phpfreaks.com/topic/136338-add-html-into/#findComment-711293 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.