From 165da619b64c6ade34366b99ef87758ef547dbdb Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Wed, 30 Jan 2008 16:36:00 +0000 Subject: added stylesheet() to html helper --- system/helpers/html_helper.php | 26 ++++++++++++++++++++++++-- user_guide/helpers/html_helper.html | 30 +++++++++++++++++++----------- 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 */ @@ -303,6 +306,25 @@ if (! function_exists('link')) // ------------------------------------------------------------------------ +/** + * Stylesheet + * + * Generates a 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 * 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');

Further examples:

-link('favicon.ico', 'shortcut icon', 'image/ico');
- // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" />

-
-
-link('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');
- // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" />
-
- -
-$link = array(
+ link('favicon.ico', 'shortcut icon', 'image/ico');
+ // <link href="http://site.com/favicon.ico" rel="shortcut icon" type="image/ico" /> +
+
+ link('feed', 'alternate', 'application/rss+xml', 'My RSS Feed');
+ // <link href="http://site.com/feed" rel="alternate" type="application/rss+xml" title="My RSS Feed" />
+

Additionally, an associative array can be passed to the link() function for complete control over all attributes and values.

+

+ $link = array(
          'href' => 'css/printer.css',
          'rel' => 'stylesheet',
          'type' => 'text/css',
@@ -105,8 +104,17 @@ $link = array(
);

link($link);
- // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />
+ // <link href="http://site.com/css/printer.css" rel="stylesheet" type="text/css" media="print" />

+

stylesheet()

+

The stylesheet() function simplifies the linking of CSS into your document. The arguments are stylesheet(href, optional rel, optional title, optional media).

+

For more complete control over the output of the tag, you may want to use the link() function.

+stylesheet('foo.css');
+ // <link href="http://site.com/foo.css" rel="stylesheet" type="text/css" media="screen" />
+
+stylesheet('foo.css', 'alternate stylesheet', 'black and white version', 'screen') .'<br>';
+ // <link href="http://site.com/foo.css" rel="alternate stylesheet" type="text/css" media="screen" title="black and white version" /> +

nbs()

Generates non-breaking spaces (&nbsp;) based on the number you submit. Example:

echo nbs(3); -- cgit v1.2.3-24-g4f1b