+

Put CSS in separated file

Benjamin Renard [2013-08-21 17:39:18]
Put CSS in separated file
Filename
projectinfos/main.php
projectinfos/style.css
projectinfos/templates/summary.php
diff --git a/projectinfos/main.php b/projectinfos/main.php
index f85f309..5115d54 100644
--- a/projectinfos/main.php
+++ b/projectinfos/main.php
@@ -9,6 +9,7 @@
 class ProjectInfosPlugin extends VGPlugin
 {
 	function __construct() {
+		$this->register_hook('header');
 		$this->register_hook('summary');
 	}

@@ -23,8 +24,10 @@ class ProjectInfosPlugin extends VGPlugin

 	function hook($type) {
 		global $conf;
-
-		if ($type == 'summary') {
+                if ($type == 'header') {
+                        echo "\t<link rel='stylesheet' href='plugins/projectinfos/style.css' type='text/css' />\n";
+                }
+		elseif ($type == 'summary') {
 			$this -> hook_summary();
 		}
 	}
diff --git a/projectinfos/style.css b/projectinfos/style.css
new file mode 100644
index 0000000..2928f57
--- /dev/null
+++ b/projectinfos/style.css
@@ -0,0 +1,23 @@
+dl.projectinfos {
+	margin:		0;
+	padding:	0;
+}
+
+dl.projectinfos dt {
+	position:		relative;
+	width:			9em;
+	left:			0.2em;
+	font-weight:		bold;
+}
+
+dl.projectinfos dd {
+	margin-left:		11em;
+	margin-top:		-1.3em;
+	padding:		0;
+}
+
+dl.projectinfos ul {
+	list-style-type:	none;
+	margin:			0;
+	padding:		0;
+}
diff --git a/projectinfos/templates/summary.php b/projectinfos/templates/summary.php
index ecba52a..5e67bba 100644
--- a/projectinfos/templates/summary.php
+++ b/projectinfos/templates/summary.php
@@ -1,31 +1,6 @@
 <?php
 global $page;
 ?>
-<style>
-dl.projectinfos {
-	margin:		0;
-	padding:	0;
-}
-
-dl.projectinfos dt {
-	position:		relative;
-	width:			7em;
-	left:			0.2em;
-	font-weight:		bold;
-}
-
-dl.projectinfos dd {
-	margin-left:		7em;
-	margin-top:		-1.3em;
-	padding:		0;
-}
-
-dl.projectinfos ul {
-	list-style-type:	none;
-	margin:			0;
-	padding:		0;
-}
-</style>
 <h1 class='projectinfos'>Project informations</h1>
 <dl class='projectinfos'>
 <dt>Description</dt>
ViewGit