bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
20.1.1
by galaxyAbstractor
* Added an simple admin panel to the codeviewer-cmssy stuff |
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
|
3 |
<head> |
|
4 |
||
5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
|
6 |
<title>URL Helper : CodeIgniter User Guide</title> |
|
7 |
||
8 |
<style type='text/css' media='all'>@import url('../userguide.css');</style> |
|
9 |
<link rel='stylesheet' type='text/css' media='all' href='../userguide.css' /> |
|
10 |
||
11 |
<script type="text/javascript" src="../nav/nav.js"></script> |
|
12 |
<script type="text/javascript" src="../nav/prototype.lite.js"></script> |
|
13 |
<script type="text/javascript" src="../nav/moo.fx.js"></script> |
|
14 |
<script type="text/javascript" src="../nav/user_guide_menu.js"></script> |
|
15 |
||
16 |
<meta http-equiv='expires' content='-1' /> |
|
17 |
<meta http-equiv= 'pragma' content='no-cache' /> |
|
18 |
<meta name='robots' content='all' /> |
|
19 |
<meta name='author' content='ExpressionEngine Dev Team' /> |
|
20 |
<meta name='description' content='CodeIgniter User Guide' /> |
|
21 |
</head> |
|
22 |
<body> |
|
23 |
||
24 |
<!-- START NAVIGATION -->
|
|
25 |
<div id="nav"><div id="nav_inner"><script type="text/javascript">create_menu('../');</script></div></div> |
|
26 |
<div id="nav2"><a name="top"></a><a href="javascript:void(0);" onclick="myHeight.toggle();"><img src="../images/nav_toggle_darker.jpg" width="154" height="43" border="0" title="Toggle Table of Contents" alt="Toggle Table of Contents" /></a></div> |
|
27 |
<div id="masthead"> |
|
28 |
<table cellpadding="0" cellspacing="0" border="0" style="width:100%"> |
|
29 |
<tr> |
|
30 |
<td><h1>CodeIgniter User Guide Version 2.1.3</h1></td> |
|
31 |
<td id="breadcrumb_right"><a href="../toc.html">Table of Contents Page</a></td> |
|
32 |
</tr> |
|
33 |
</table> |
|
34 |
</div> |
|
35 |
<!-- END NAVIGATION -->
|
|
36 |
||
37 |
||
38 |
<!-- START BREADCRUMB -->
|
|
39 |
<table cellpadding="0" cellspacing="0" border="0" style="width:100%"> |
|
40 |
<tr> |
|
41 |
<td id="breadcrumb"> |
|
42 |
<a href="http://codeigniter.com/">CodeIgniter Home</a> › |
|
43 |
<a href="../index.html">User Guide Home</a> › |
|
44 |
URL Helper |
|
45 |
</td> |
|
46 |
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="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> |
|
47 |
</tr> |
|
48 |
</table> |
|
49 |
<!-- END BREADCRUMB -->
|
|
50 |
||
51 |
<br clear="all" /> |
|
52 |
||
53 |
||
54 |
<!-- START CONTENT -->
|
|
55 |
<div id="content"> |
|
56 |
||
57 |
||
58 |
<h1>URL Helper</h1> |
|
59 |
||
60 |
<p>The URL Helper file contains functions that assist in working with URLs.</p> |
|
61 |
||
62 |
||
63 |
<h2>Loading this Helper</h2> |
|
64 |
||
65 |
<p>This helper is loaded using the following code:</p> |
|
66 |
<code>$this->load->helper('url');</code> |
|
67 |
||
68 |
<p>The following functions are available:</p> |
|
69 |
||
70 |
<h2>site_url()</h2> |
|
71 |
||
72 |
<p>Returns your site URL, as specified in your config file. The index.php file (or whatever you have set as your |
|
73 |
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, and the <dfn>url_suffix</dfn> as set in your config file.</p> |
|
74 |
||
75 |
<p>You are encouraged to use this function any time you need to generate a local URL so that your pages become more portable |
|
76 |
in the event your URL changes.</p> |
|
77 |
||
78 |
<p>Segments can be optionally passed to the function as a string or an array. Here is a string example:</p> |
|
79 |
||
80 |
<code>echo site_url("news/local/123");</code> |
|
81 |
||
82 |
<p>The above example would return something like: http://example.com/index.php/news/local/123</p> |
|
83 |
||
84 |
<p>Here is an example of segments passed as an array:</p> |
|
85 |
||
86 |
<code> |
|
87 |
$segments = array('news', 'local', '123');<br /> |
|
88 |
<br /> |
|
89 |
echo site_url($segments);</code> |
|
90 |
||
91 |
||
92 |
<h2>base_url()</h2> |
|
93 |
<p>Returns your site base URL, as specified in your config file. Example:</p> |
|
94 |
<code>echo base_url();</code> |
|
95 |
||
96 |
<p>This function returns the same thing as site_url, without the <dfn>index_page</dfn> or <dfn>url_suffix</dfn> being appended.</p> |
|
97 |
||
98 |
<p>Also like site_url, you can supply segments as a string or an array. Here is a string example:</p> |
|
99 |
||
100 |
<code>echo base_url("blog/post/123");</code> |
|
101 |
||
102 |
<p>The above example would return something like: http://example.com/blog/post/123</p> |
|
103 |
||
104 |
<p>This is useful because unlike site_url(), you can supply a string to a file, such as an image or stylesheet. For example:</p> |
|
105 |
||
106 |
<code>echo base_url("images/icons/edit.png");</code> |
|
107 |
||
108 |
<p>This would give you something like: http://example.com/images/icons/edit.png</p> |
|
109 |
||
110 |
||
111 |
<h2>current_url()</h2> |
|
112 |
<p>Returns the full URL (including segments) of the page being currently viewed.</p> |
|
113 |
||
114 |
||
115 |
<h2>uri_string()</h2> |
|
116 |
<p>Returns the URI segments of any page that contains this function. For example, if your URL was this:</p> |
|
117 |
<code>http://some-site.com/blog/comments/123</code> |
|
118 |
||
119 |
<p>The function would return:</p> |
|
120 |
<code>/blog/comments/123</code> |
|
121 |
||
122 |
||
123 |
<h2>index_page()</h2> |
|
124 |
<p>Returns your site "index" page, as specified in your config file. Example:</p> |
|
125 |
<code>echo index_page();</code> |
|
126 |
||
127 |
||
128 |
||
129 |
<h2>anchor()</h2> |
|
130 |
||
131 |
<p>Creates a standard HTML anchor link based on your local site URL:</p> |
|
132 |
||
133 |
<code><a href="http://example.com">Click Here</a></code> |
|
134 |
||
135 |
<p>The tag has three optional parameters:</p> |
|
136 |
||
137 |
<code>anchor(<var>uri segments</var>, <var>text</var>, <var>attributes</var>)</code> |
|
138 |
||
139 |
<p>The first parameter can contain any segments you wish appended to the URL. As with the <dfn>site_url()</dfn> function above, |
|
140 |
segments can be a string or an array.</p> |
|
141 |
||
142 |
<p><strong>Note:</strong> If you are building links that are internal to your application do not include the base URL (http://...). This |
|
143 |
will be added automatically from the information specified in your config file. Include only the URI segments you wish appended to the URL.</p> |
|
144 |
||
145 |
<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> |
|
146 |
||
147 |
<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> |
|
148 |
||
149 |
<p>Here are some examples:</p> |
|
150 |
||
151 |
<code>echo anchor('news/local/123', 'My News', 'title="News title"');</code> |
|
152 |
||
153 |
<p>Would produce: <a href="http://example.com/index.php/news/local/123" title="News title">My News</a></p> |
|
154 |
||
155 |
<code>echo anchor('news/local/123', 'My News', array('title' => 'The best news!'));</code> |
|
156 |
||
157 |
<p>Would produce: <a href="http://example.com/index.php/news/local/123" title="The best news!">My News</a></p> |
|
158 |
||
159 |
||
160 |
<h2>anchor_popup()</h2> |
|
161 |
||
162 |
<p>Nearly identical to the <dfn>anchor()</dfn> function except that it opens the URL in a new window. |
|
163 |
||
164 |
You can specify JavaScript window attributes in the third parameter to control how the window is opened. If |
|
165 |
the third parameter is not set it will simply open a new window with your own browser settings. Here is an example |
|
166 |
with attributes:</p> |
|
167 |
||
168 |
<code> |
|
169 |
||
170 |
$atts = array(<br /> |
|
171 |
'width' => '800',<br /> |
|
172 |
'height' => '600',<br /> |
|
173 |
'scrollbars' => 'yes',<br /> |
|
174 |
'status' => 'yes',<br /> |
|
175 |
'resizable' => 'yes',<br /> |
|
176 |
'screenx' => '0',<br /> |
|
177 |
'screeny' => '0'<br /> |
|
178 |
);<br /> |
|
179 |
<br /> |
|
180 |
echo anchor_popup('news/local/123', 'Click Me!', $atts);</code> |
|
181 |
||
182 |
<p>Note: The above attributes are the function defaults so you only need to set the ones that are different from what you need. |
|
183 |
If you want the function to use all of its defaults simply pass an empty array in the third parameter:</p> |
|
184 |
||
185 |
<code>echo anchor_popup('news/local/123', 'Click Me!', array());</code> |
|
186 |
||
187 |
||
188 |
<h2>mailto()</h2> |
|
189 |
||
190 |
<p>Creates a standard HTML email link. Usage example:</p> |
|
191 |
||
192 |
<code>echo mailto('me@my-site.com', 'Click Here to Contact Me');</code> |
|
193 |
||
194 |
<p>As with the <dfn>anchor()</dfn> tab above, you can set attributes using the third parameter.</p> |
|
195 |
||
196 |
||
197 |
<h2>safe_mailto()</h2> |
|
198 |
||
199 |
<p>Identical to the above function except it writes an obfuscated version of the mailto tag using ordinal numbers |
|
200 |
written with JavaScript to help prevent the email address from being harvested by spam bots.</p> |
|
201 |
||
202 |
||
203 |
<h2>auto_link()</h2> |
|
204 |
||
205 |
<p>Automatically turns URLs and email addresses contained in a string into links. Example:</p> |
|
206 |
||
207 |
<code>$string = auto_link($string);</code> |
|
208 |
||
209 |
<p>The second parameter determines whether URLs and emails are converted or just one or the other. Default behavior is both |
|
210 |
if the parameter is not specified. Email links are encoded as safe_mailto() as shown above.</p> |
|
211 |
||
212 |
<p>Converts only URLs:</p> |
|
213 |
<code>$string = auto_link($string, 'url');</code> |
|
214 |
||
215 |
<p>Converts only Email addresses:</p> |
|
216 |
<code>$string = auto_link($string, 'email');</code> |
|
217 |
||
218 |
<p>The third parameter determines whether links are shown in a new window. The value can be TRUE or FALSE (boolean):</p> |
|
219 |
<code>$string = auto_link($string, 'both', TRUE);</code> |
|
220 |
||
221 |
||
222 |
<h2>url_title()</h2> |
|
223 |
<p>Takes a string as input and creates a human-friendly URL string. This is useful if, for example, you have a blog |
|
224 |
in which you'd like to use the title of your entries in the URL. Example:</p> |
|
225 |
||
226 |
<code>$title = "What's wrong with CSS?";<br /> |
|
227 |
<br /> |
|
228 |
$url_title = url_title($title);<br /> |
|
229 |
<br /> |
|
230 |
// Produces: Whats-wrong-with-CSS |
|
231 |
</code> |
|
232 |
||
233 |
||
234 |
<p>The second parameter determines the word delimiter. By default dashes are used.</p> |
|
235 |
||
236 |
<code>$title = "What's wrong with CSS?";<br /> |
|
237 |
<br /> |
|
238 |
$url_title = url_title($title, '_');<br /> |
|
239 |
<br /> |
|
240 |
// Produces: Whats_wrong_with_CSS |
|
241 |
</code> |
|
242 |
||
243 |
<p>The third parameter determines whether or not lowercase characters are forced. By default they are not. Options are boolean <dfn>TRUE</dfn>/<dfn>FALSE</dfn>:</p> |
|
244 |
||
245 |
<code>$title = "What's wrong with CSS?";<br /> |
|
246 |
<br /> |
|
247 |
$url_title = url_title($title, '_', TRUE);<br /> |
|
248 |
<br /> |
|
249 |
// Produces: whats_wrong_with_css |
|
250 |
</code> |
|
251 |
||
252 |
<h3>prep_url()</h3> |
|
253 |
<p>This function will add <kbd>http://</kbd> in the event that a scheme is missing from a URL. Pass the URL string to the function like this:</p> |
|
254 |
<code> |
|
255 |
$url = "example.com";<br /><br /> |
|
256 |
$url = prep_url($url);</code> |
|
257 |
||
258 |
||
259 |
||
260 |
||
261 |
<h2>redirect()</h2> |
|
262 |
||
263 |
<p>Does a "header redirect" to the URI specified. If you specify the full site URL that link will be build, but for local links simply providing the URI segments |
|
264 |
to the controller you want to direct to will create the link. The function will build the URL based on your config file values.</p> |
|
265 |
||
266 |
<p>The optional second parameter allows you to choose between the "location" |
|
267 |
method (default) or the "refresh" method. Location is faster, but on Windows servers it can sometimes be a problem. The optional third parameter allows you to send a specific HTTP Response Code - this could be used for example to create 301 redirects for search engine purposes. The default Response Code is 302. The third parameter is <em>only</em> available with 'location' redirects, and not 'refresh'. Examples:</p> |
|
268 |
||
269 |
<code>if ($logged_in == FALSE)<br /> |
|
270 |
{<br /> |
|
271 |
redirect('/login/form/', 'refresh');<br /> |
|
272 |
}<br /> |
|
273 |
<br /> |
|
274 |
// with 301 redirect<br /> |
|
275 |
redirect('/article/13', 'location', 301);</code> |
|
276 |
||
277 |
<p class="important"><strong>Note:</strong> In order for this function to work it must be used before anything is outputted |
|
278 |
to the browser since it utilizes server headers.<br /> |
|
279 |
<strong>Note:</strong> For very fine grained control over headers, you should use the <a href="../libraries/output.html">Output Library</a>'s set_header() function.</p> |
|
280 |
||
281 |
||
282 |
||
283 |
||
284 |
||
285 |
||
286 |
</div> |
|
287 |
<!-- END CONTENT -->
|
|
288 |
||
289 |
||
290 |
<div id="footer"> |
|
291 |
<p> |
|
292 |
Previous Topic: <a href="typography_helper.html">Typography Helper</a> |
|
293 |
·
|
|
294 |
<a href="#top">Top of Page</a> · |
|
295 |
<a href="../index.html">User Guide Home</a> · |
|
296 |
Next Topic: <a href="xml_helper.html">XML Helper</a> |
|
297 |
</p> |
|
298 |
<p><a href="http://codeigniter.com">CodeIgniter</a> · Copyright © 2006 - 2012 · <a href="http://ellislab.com/">EllisLab, Inc.</a></p> |
|
299 |
</div> |
|
300 |
||
301 |
</body> |
|
302 |
</html> |