summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2008-01-30 17:36:00 +0100
committerDerek Allard <derek.allard@ellislab.com>2008-01-30 17:36:00 +0100
commit165da619b64c6ade34366b99ef87758ef547dbdb (patch)
tree50475714e8e786150c273ab92b54fbeac32a8556
parent432e97322ad518468235649ad25974eef3f3d39f (diff)
added stylesheet() to html helper
-rw-r--r--system/helpers/html_helper.php26
-rw-r--r--user_guide/helpers/html_helper.html30
2 files changed, 43 insertions, 13 deletions
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index d887be6ce..660d867bd 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -230,8 +230,11 @@ if (! function_exists('image'))
* Generates link to a CSS file
*
* @access public
- * @param mixed stylesheet name(s)
- * @param string media type
+ * @param mixed stylesheet hrefs or an array
+ * @param string rel
+ * @param string type
+ * @param string title
+ * @param string media
* @param boolean should index_page be added to the css path
* @return string
*/
@@ -304,6 +307,25 @@ if (! function_exists('link'))
// ------------------------------------------------------------------------
/**
+ * Stylesheet
+ *
+ * Generates a <link /> to a CSS
+ *
+ * @access public
+ * @param array
+ * @return string
+ */
+if (! function_exists('stylesheet'))
+{
+ function stylesheet($href = '', $rel = 'stylesheet', $title = '', $media = 'screen')
+ {
+ return link($href, $rel, 'text/css', $title, $media);
+ }
+}
+
+// ------------------------------------------------------------------------
+
+/**
* Generates meta tags from an array of key/values
*
* @access public
diff --git a/user_guide/helpers/html_helper.html b/user_guide/helpers/html_helper.html
index 7abe01af9..5ddadd717 100644
--- a/user_guide/helpers/html_helper.html
+++ b/user_guide/helpers/html_helper.html
@@ -88,16 +88,15 @@ link('css/mystyles.css');<br />
<p>Further examples:</p>
<code>
-link('favicon.ico', 'shortcut icon', 'image/ico');<br />
- // &lt;link href=&quot;http://site.com/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/ico&quot; /&gt; </p>
-<br />
-<br />
-link('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
- // &lt;link href=&quot;http://site.com/feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;My RSS Feed&quot; /&gt; <br />
-<br />
-
-<br />
-$link = array(<br />
+ link('favicon.ico', 'shortcut icon', 'image/ico');<br />
+ // &lt;link href=&quot;http://site.com/favicon.ico&quot; rel=&quot;shortcut icon&quot; type=&quot;image/ico&quot; /&gt;
+ <br />
+ <br />
+ link('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');<br />
+ // &lt;link href=&quot;http://site.com/feed&quot; rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;My RSS Feed&quot; /&gt; </code>
+<p>Additionally, an associative array can be passed to the link() function for complete control over all attributes and values.</p>
+<p><code>
+ $link = array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'href' =&gt; 'css/printer.css',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'rel' =&gt; 'stylesheet',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'type' =&gt; 'text/css',<br />
@@ -105,8 +104,17 @@ $link = array(<br />
);<br />
<br />
link($link);<br />
- // &lt;link href=&quot;http://site.com/css/printer.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt;</code>
+ // &lt;link href=&quot;http://site.com/css/printer.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt;</code></p>
+<h2>stylesheet()</h2>
+<p>The stylesheet() function simplifies the linking of CSS into your document. The arguments are stylesheet(href, optional rel, optional title, optional media).</p>
+<p>For more complete control over the output of the tag, you may want to use the link() function.</p>
+<code>stylesheet('foo.css');<br />
+ // &lt;link href=&quot;http://site.com/foo.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;<br />
+<br />
+stylesheet('foo.css', 'alternate stylesheet', 'black and white version', 'screen') .'&lt;br&gt;';<br />
+ // &lt;link href=&quot;http://site.com/foo.css&quot; rel=&quot;alternate stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; title=&quot;black and white version&quot; /&gt;
+</code>
<h2>nbs()</h2>
<p>Generates non-breaking spaces (&amp;nbsp;) based on the number you submit. Example:</p>
<code>echo nbs(3);</code>