diff options
author | admin <devnull@localhost> | 2006-08-25 19:25:49 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-08-25 19:25:49 +0200 |
commit | b0dd10f8171945e0c1f3527dd1e9d18b043e01a7 (patch) | |
tree | c3583ba09e72217683c4304f4690df6ce39ba731 /user_guide/helpers/url_helper.html |
Initial Import
Diffstat (limited to 'user_guide/helpers/url_helper.html')
-rw-r--r-- | user_guide/helpers/url_helper.html | 269 |
1 files changed, 269 insertions, 0 deletions
diff --git a/user_guide/helpers/url_helper.html b/user_guide/helpers/url_helper.html new file mode 100644 index 000000000..a8f5c14d6 --- /dev/null +++ b/user_guide/helpers/url_helper.html @@ -0,0 +1,269 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+<head>
+
+<title>Code Igniter User Guide</title>
+
+<style type='text/css' media='all'>@import url('../userguide.css');</style>
+<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' />
+
+<script type="text/javascript" src="../scripts/nav.js"></script>
+<script type="text/javascript" src="../scripts/prototype.lite.js"></script>
+<script type="text/javascript" src="../scripts/moo.fx.js"></script>
+<script type="text/javascript">
+window.onload = function() {
+ myHeight = new fx.Height('nav', {duration: 400});
+ myHeight.hide();
+}
+</script>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv='expires' content='-1' />
+<meta http-equiv= 'pragma' content='no-cache' />
+<meta name='robots' content='all' />
+<meta name='author' content='Rick Ellis' />
+<meta name='description' content='Code Igniter User Guide' />
+
+</head>
+<body>
+
+<!-- START NAVIGATION -->
+<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div>
+<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle.jpg" width="153" height="44" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div>
+<div id="masthead">
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td><h1>Code Igniter User Guide Version 1.4.0</h1></td>
+<td id="breadcrumb_right"><a href="../toc.html">Full Table of Contents</a></td>
+</tr>
+</table>
+</div>
+<!-- END NAVIGATION -->
+
+
+<!-- START BREADCRUMB -->
+<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
+<tr>
+<td id="breadcrumb">
+<a href="http://www.codeigniter.com/">Code Igniter Home</a> ›
+<a href="../index.html">User Guide Home</a> ›
+URL Helper
+</td>
+<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="www.codeigniter.com/user_guide/" />Search User Guide <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" /> <input type="submit" class="submit" name="sa" value="Go" /></form></td>
+</tr>
+</table>
+<!-- END BREADCRUMB -->
+
+<br clear="all" />
+
+
+<!-- START CONTENT -->
+<div id="content">
+
+
+<h1>URL Helper</h1>
+
+<p>The URL Helper file contains functions that assist in working with URLs.</p>
+
+
+<h2>Loading this Helper</h2>
+
+<p>This helper is loaded using the following code:</p>
+<code>$this->load->helper('url');</code>
+
+<p>The following functions are available:</p>
+
+<h2>site_url()</h2>
+
+<p>Returns your site URL, as specified in your config file. The index.php file (or whatever you have set as your
+site <dfn>index_page</dfn> in your config file) will be added to the URL, as will any URI segments you pass to the function.</p>
+
+<p>You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable
+in the event your URL changes.</p>
+
+<p>Segments can be optionally passed to the function as a string or an array. Here is a string example:</p>
+
+<code>echo site_url("news/local/123");</code>
+
+<p>The above example would return something like: http://www.your-site.com/index.php/news/local/123</p>
+
+<p>Here is an example of segments passed as an array:</p>
+
+<code>
+$segments = array('news', 'local', '123');<br />
+<br />
+echo site_url($segments);</code>
+
+
+<h2>base_url()</h2>
+<p>Returns your site base URL, as specified in your config file. Example:</p>
+<code>echo base_url();</code>
+
+
+<h2>index_page()</h2>
+<p>Returns your site "index" page, as specified in your config file. Example:</p>
+<code>echo index_page();</code>
+
+
+
+<h2>anchor()</h2>
+
+<p>Creates a standard HTML anchor link based on your local site URL:</p>
+
+<code><a href="http://www.your-site.com">Click Here</a></code>
+
+<p>The tag has three optional parameters:</p>
+
+<code>anchor(<var>uri segments</var>, <var>text</var>, <var>attributes</var>)</code>
+
+<p>The first parameter can contain any segments you wish appended to the URL. As with the <dfn>site_url()</dfn> function above,
+segments can be a string or an array. Note: Do not include the base URL. It will be built as specified in your config file. Include
+only the URI segments you wish appended to the URL.</p>
+
+<p>The second segment is the text you would like the link to say. If you leave it blank, the URL will be used.</p>
+
+<p>The third parameter can contain a list of attributes you would like added to the link. The attributes can be a simple string or an associative array.</p>
+
+<p>Here are some examples:</p>
+
+<code>echo anchor(<var>news/local/123</var>, <var>My News</var>);</code>
+
+<p>Would produce: <a href="http://www.your-site.com/index.php/news/local/123" title="My News">My News</a></p>
+
+<code>echo anchor(<var>news/local/123</var>, <var>My News</var>, <var>array('title' => 'The best news!')</var>);</code>
+
+<p>Would produce: <a href="http://www.your-site.com/index.php/news/local/123" title="The best news!">My News</a></p>
+
+
+<h2>anchor_popup()</h2>
+
+<p>Nearly identical to the <dfn>anchor()</dfn> function except that it opens the URL in a new window.
+
+You can specify JavaScript window attributes in the third parameter to control how the window is opened. If
+the third parameter is not set it will simply open a new window with your own browser settings. Here is an example
+with attributes:</p>
+
+<code>
+
+$atts = array(<br />
+ 'width' => '800',<br />
+ 'height' => '600',<br />
+ 'scrollbars' => 'yes',<br />
+ 'status' => 'yes',<br />
+ 'resizable' => 'yes',<br />
+ 'screenx' => '0',<br />
+ 'screeny' => '0'<br />
+ );<br />
+<br />
+echo anchor_popup(news/local/123, 'Click Me!', $atts);</code>
+
+<p>Note: The above attributes are the function defaults so you only need to set the ones that are different from what you need.
+If you want the function to use all of its defaults simply pass an empty array in the third parameter:</p>
+
+<code>echo anchor_popup(news/local/123, 'Click Me!', array());</code>
+
+
+<h2>mailto()</h2>
+
+<p>Creates a standard HTML email link. Usage example:</p>
+
+<code>echo mailto('me@my-site.com', 'Click Here to Contact Me');</code>
+
+<p>As with the <dfn>anchor()</dfn> tab above, you can set attributes using the third parameter.</p>
+
+
+<h2>safe_mailto()</h2>
+
+<p>Identical to the above function except it writes an obfuscated version of the mailto tag using ordinal numbers
+written with JavaScript to help prevent the email address from being harvested by spam bots.</p>
+
+
+<h2>auto_link()</h2>
+
+<p>Automatically turns URLs and email addresses contained in a string into links. Example:</p>
+
+<code>$string = auto_link($string);</code>
+
+<p>The second parameter determines whether URLs and emails are converted or just one or the other. Default behavior is both
+if the parameter is not specified</p>
+
+<p>Converts only URLs:</p>
+<code>$string = auto_link($string, 'url');</code>
+
+<p>Converts only Email addresses:</p>
+<code>$string = auto_link($string, 'email');</code>
+
+</p>The third parameter determines whether links are shown in a new window. The value can be TRUE or FALSE (boolean):</p>
+<code>$string = auto_link($string, 'both', TRUE);</code>
+
+
+<h2>url_title()</h2>
+<p>Takes a string as input and creates a human-friendly URL string. This is useful if, for example, you have a blog
+in which you'd like to use the title of your entries in the URL. Example:</p>
+
+<code>$title = "What's wrong with CSS?";<br />
+<br />
+$url_title = url_title($title);<br />
+<br />
+// Produces: whats-wrong-with-css
+</code>
+
+
+<p>The second parameter determines the word delimiter. By default dashes are used. Options are: <dfn>dash</dfn>, or <dfn>underscore</dfn>:</p>
+
+<code>$title = "What's wrong with CSS?";<br />
+<br />
+$url_title = url_title($title, 'underscore');<br />
+<br />
+// Produces: whats_wrong_with_css
+</code>
+
+
+<h3>prep_url()</h3>
+<p>This function will add <kbd>http://</kbd> in the event it is missing from a URL. Pass the URL string to the function like this:</p>
+<code>
+$url = "www.some-site.com";<br /><br />
+$url = prep_url($url);</code>
+
+
+
+
+<h2>redirect()</h2>
+
+<p>Does a "header redirect" to the local URI specified. Just like other functions in this helper, this one is designed
+to redirect to a local URL within your site. You will <strong>not</strong> specify the full site URL, but rather simply the URI segments
+to the controller you want to direct to. The function will build the URL based on your config file values.</p>
+
+<p>The second parameter allows you to choose between the "location"
+method or the "refresh" method. Location is faster, but on Windows servers it can sometimes be a problem. Example:</p>
+
+<code>if ($logged_in == FALSE)<br />
+{<br />
+ redirect('/login/form/', 'refresh');<br />
+}</code>
+
+<p class="important"><strong>Note:</strong> In order for this function to work it must be used before anything is outputted
+to the browser since it utilizes server headers.</p>
+
+
+
+
+
+
+</div>
+<!-- END CONTENT -->
+
+
+<div id="footer">
+<p>
+Previous Topic: <a href="typography_helper.html">Typography Helper</a>
+ ·
+<a href="#top">Top of Page</a> ·
+<a href="../index.html">User Guide Home</a> ·
+Next Topic: <a href="xml_helper.html">XML Helper</a>
+<p>
+<p><a href="http://www.codeigniter.com">Code Igniter</a> · Copyright © 2006 · <a href="http://www.pmachine.com">pMachine, Inc.</a></p>
+</div>
+
+</body>
+</html>
\ No newline at end of file |