OSDN Git Service

MERGE: リビジョン1755のマージ。SkinクラスでActionsクラス以外のバックエンドクラスを利用可能に。
[nucleus-jp/nucleus-next.git] / nucleus / documentation / tips.html
1 <!DOCTYPE html
2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml">
5 <head>
6         <!-- $Id: tips.html 1463 2010-11-08 21:40:13Z ftruscot $ -->
7         <title>Nucleus - Tips and suggestions</title>
8         <link rel="stylesheet" type="text/css" href="styles/manual.css" />
9 </head>
10 <body>
11
12 <div class="heading">
13 <a name="top" />
14 Tips &amp; Suggestions
15 </div>
16
17 <h1>Introduction</h1>
18
19 <p>
20 <a href="index.html">Back to the manual</a>
21 </p>
22
23 <p>
24 This file contains tips and suggestions that might prove useful.
25 </p>
26
27 <h1><a name="toc"></a>Table Of Contents</h1>
28
29 <ul>
30         <li>
31                 <a href="#searchengines">How to get your archives into search engines?</a>
32                 <ul>
33                         <li><a href="#searchengines-fancyurls">Fancy URLs</a></li>
34                         <li><a href="#searchengines-rewrite">mod_rewrite</a></li>
35                         <li><a href="#fancyurls-2">Fancy URLs 2</a></li>
36                 </ul>
37         </li>
38         <li><a href="#filepermissions">How to set file/dir permissions?</a></li>
39         <li><a href="#backups">How to restore backups</a></li>
40         <li><a href="#newblog">How to create a new weblogs</a></li>
41         <li><a href="#xhtml">XHTML support</a></li>
42         <li><a href="#specialskinpart">How to create a Special skin part</a></li>
43 <!--
44         <li><a href="#"></a></li>
45         <li><a href="#"></a></li>
46         <li><a href="#"></a></li>
47 -->
48 </ul>
49
50
51
52
53
54
55
56
57
58
59 <h1>Getting your archives into search engines like Google <a name="searchengines" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>
60
61 <div class="note">
62 <b>Note:</b> The solutions described here might not work on your system.
63 </div>
64
65 <p>
66 Nucleus creates archives dynamically on users requests. The URL is then of the form <code>index.php?archive=2001-09&amp;blogid=1</code>. Unfortunately, Google and other search engines don't like to index pages with a question mark in it, or with too much arguments. This is because their spiders might get trapped going too deep.
67 </p>
68
69 <p>Two solutions are listed below. They're not guaranteed to work, however (wether they work or not depends on the webserver configuration)</p>
70
71 <ol>
72         <li><a href="#searchengines-fancyurls">Fancy URLs</a></li>
73         <li><a href="#searchengines-rewrite">mod_rewrite</a></li>
74         <li><a href="#fancyurls-2">Fancy URLs 2</a></li>
75 </ol>
76
77
78 <h2><a name="searchengines-fancyurls"></a>Fancy URLs</h2>
79
80 <p>Nucleus v2.0 has a new option in the global settings 'URL mode'. Setting it to 'Fancy URL' mode, and performing the steps below, will make your URLs look like <code>http://example.org/item/1234</code> instead of <code>http://example.org/index.php?itemid=1234</code>. Search engines like these URLs better.</p>
81
82 <p>Installation steps:</p>
83
84 <ol>
85         <li>Copy all files from the <code>/extra/fancyurls</code> directory (except for <code>index.html</code>) to your main nucleus dir (that's where your <code>index.php</code> and <code>action.php</code> file are)</li>
86         <li>If you have an already existing <code>.htaccess</code> file (most ftp-programs don't show hidden files by default, so don't start uploading it without checking your server). If you do, download that old one first, and copy the contents of the new <code>.htaccess</code> file (from the fancyurls folder) in your old one, and upload that...</li>
87         <li>Edit the <code>fancyurls.config.php</code> file so that <code>$CONF['Self']</code> points to your main directory. <br /><strong>NOTE: this time, and only this time, the URL should <em>NOT</em> end in a slash</strong></li>
88         <li>Also edit the <code>$CONF['Self']</code> variable in your <code>index.php</code>, if you don't want to end up with <code>index.php/item/1234</code> urls when people come via that way</li>
89         <li>Enable 'Fancy URLs' in the Nucleus admin area (nucleus management / edit settings)</li>
90         <li>Off you go!</li>
91 </ol>
92
93 <p>When it doesn't work (e.g. you receive an Internal Server Error): bad luck... Remove the files again (don't forget the hidden file <code>.htaccess</code>) and reset the Fancy URLs setting in the admin area.</p>
94
95
96
97 <h2><a name="searchengines-rewrite"></a>mod_rewrite</h2>
98
99 <p>
100 This second possible solution will only work on servers running Apache, and when you have the right to do so. What we will do is 'disguise' the archives as regular HTML pages
101 </p>
102
103 <p>
104 Create a file called <code>.htaccess</code> (leading dot!) with the following contents:
105 </p>
106
107 <pre>
108 RewriteEngine On
109 RewriteRule ^archive-([0-9]+)-([0-9]+)-([0-9]+).html+ index.php?archive=$2-$3&amp;blogid=$1
110 RewriteRule ^item-([0-9]+).html+ index.php?itemid=$1
111 RewriteRule ^archivelist-([a-z]+).html+ index.php?archivelist=$1
112 </pre>
113
114 <p>
115 Now upload this file to the directory that contains <i>index.php</i> and <i>config.php</i>. Open your browser and try to open <code>archive-1-2001-09.html</code>. If it works, continue to read. If you get a 500 error (internal server error), it does not work on your server, so delete the .htaccess file.
116 </p>
117
118 <p>
119 Now all you have to do is to update the link to your blog archives into <code>archivelist-<i>shortblogname</i>.html</code> and make the following changes to your archivelist item template:
120 </p>
121
122 <pre>
123 &lt;a href="archive-&lt;%blogid%&gt;-&lt;%year%&gt;-&lt;%month%&gt;.html"&gt;...&lt;/a&gt;
124 </pre>
125
126 <p>
127 And now, wait until Google comes spidering again...
128 </p>
129
130
131 <h2><a name="fancyurls-2"></a>Fancy URLs 2</h2>
132
133 <p>Nucleus CMS version 3.3 offers an easier way to enable the basic Fancy URLs. There are only three steps necessary to install this solution:</p>
134
135 <ol><li>Copy or move the <code>.htaccess</code> file from <code>extra/fancyurl-2</code> to the root directory of your Nucleus CMS installation.</li>
136 <li>Edit the <code>index.php</code> file which you can find in your root directory. Change value of the <code>CONF['Self']</code> from the  default value (<code>'index.php'</code>) to the URL that points to your root directory, for example:<br />
137 <pre>CONF['Self'] = 'http://yourdomain.com/yourNucleusDirectory';</pre>
138 Don't use a slash at the end.<br /></li>
139 <li>Enable the 'Fancy URLs' in the Nucleus admin area, you can find this setting under <em>Management &gt; Configuration</em>.</li></ol>
140
141 <p>Everything done.</p>
142
143 <p>If you want to use rewritten URLs like <code>item/this-is-a-title</code> you can find plugin solutions for it in the Nucleus Plugin Wiki, for example <a href="http://wakka.xiffy.nl/fancierurl2">NP_FancierURL2</a>.</p>
144
145 <h1>How to set file/dir permissions <a name="filepermissions" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>
146
147 <p>
148 To enable some features of Nucleus, changing file permissions is required. A small guide on how to do this using an FTP client is given below.
149 </p>
150
151 <p>
152 First of all, you'll need an FTP client that supports file permission changing. In this example, we'll use CuteFTP. You can <a href="http://www.cuteftp.com/products/cuteftp/">download a free trial version</a> if you don't have it.
153 </p>
154
155 <p>
156 To change the permissions of a file or directory, create an FTP connection to your website and search for that file or directory in the hierarchy. Select the file by clicking on it.
157 </p>
158
159 <p>
160 Open the menu <tt>Commands &gt; File Actions &gt; CHMOD...</tt> for a file, or <tt>Commands &gt; Directory &gt; CHMOD...</tt> for a directory.
161 </p>
162
163 <div class="screenshot">
164         <img src="pics/chmod_menu.png" width="381" height="218" alt="menu" />
165 </div>
166
167 <p>
168 A window will pop up:
169 </p>
170
171 <div class="screenshot">
172         <img src="pics/chmod_window.png" width="260" height="326" alt="The window that pops up" />
173 </div>
174
175 <p>
176 On the bottom, you can enter the code that's given in the documentation (e.g. 755 or 444). Click the <tt>OK</tt> button and the changes will be applied. You're finished now.
177 </p>
178
179 <h1>How to restore backups <a name="backups" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>
180
181 <p>
182 Nucleus has a backup/restore option that super-admins can use to create a backup of the database. It's strongly encouraged to take a backup regularly (weekly or so). The backup-files that are returned are files containing standard SQL-queries, that reconstruct the state of the database as it was when the backup was created.
183 </p>
184
185 <p>
186 While backing up is easy, and restoring should also be easy, problems might pop up when your database is fucked up beyond repair. In that case, the repair function might become unaccessible. Below are some ways you can restore your database in that case:
187 </p>
188
189 <div class="note">
190 If you're backup was gzipped, unzip if first (it contains an sql file)
191 </div>
192
193
194 <h2>Possibility 1: Web-based</h2>
195
196 <p>
197 If you have a web-based interface through which you can manage your database (e.g. <a href="http://phpmyadmin.sourceforge.net/">PHPMyAdmin</a>), there's most likely an option where you can import a file into the database. Use this function to restore your database.
198 </p>
199
200 <h2>Possibility 2: Shell-access</h2>
201
202 <p>
203 If you have a shell account, restoring a backup can be done by running the <tt>mysql</tt> program with the following arguments:
204 </p>
205
206 <pre>
207 mysql -u <i>username</i> -p -h <i>hostname</i> <i>databasename</i> &lt; <i>backupfile.sql</i>
208 </pre>
209
210
211 <h1>How to create a new weblog <a name="newblog" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>
212
213 <h2>1. Creating the weblog</h2>
214
215 <p>As a superadmin, you can create new weblogs from the 'Nucleus Management' screen. They will then show up on the admin area.</p>
216
217 <h2>2. Accessing your new weblog</h2>
218
219 <p>There are several ways in which you can make your new weblog accessible.</p>
220
221 <ol>
222         <li>Using a <strong><code>blogid</code> attribute</strong> in the URL:
223                 <pre><code>http://yourhost.com/index.php?blogid=<i>2</i></code></pre>
224                 (You can find the blogid in the admin area, when hovering over the blog name in the blog list)
225         </li>
226         <li>
227                 By creating a <strong>copy of the <code>index.php</code> file</strong> (in this example, our file is named <tt>copy.php</tt>), and editing the contents of the file to look like this:
228                 <pre><code>$CONF['Self'] = '<i>copy.php</i>';
229 include('./config.php');
230 selectBlog('<i>shortblogname</i>');
231 selector();
232
233 ?></code></pre>
234                 (You can find the short blog name in the admin area, when hovering over the blog name in the blog list)
235         </li>
236 </ol>
237
238 <h2>Extra methods to use in copy.php</h2>
239
240 <p>The <tt>selectBlog</tt> is only one of the methods which you can use in copies of <tt>index.php</tt> files. Here's a list of the available calls:</p>
241
242 <table><tr>
243         <th>Method</th>
244         <th>Description</th>
245 </tr><tr>
246         <td><code>selectBlog('shortblogname');</code></td>
247         <td>Makes sure a certain blog gets selected</td>
248 </tr><tr>
249         <td><code>selectSkin('skinname');</code></td>
250         <td>Makes sure a certain skin gets selected</td>
251 </tr><tr>
252         <td><code>selectCategory(1234);</code></td>
253         <td>Makes sure a certain category gets selected. Takes a category id as argument. Also accepts a category name (keep in mind that this can cause problems if multiple categories have the same name)</td>
254 </tr><tr>
255         <td><code>selectItem(1234);</code></td>
256         <td>Makes sure a certain item gets selected</td>
257 </tr><tr>
258         <td><code>selectLanguage('french');</code></td>
259         <td>Makes sure a certain language gets used (note: might produce PHP warnings)</td>
260 </tr><tr>
261         <td><code>selectSpecialSkinType('construction');</code></td>
262         <td>Makes sure a certain special skin type gets used (note: if used by itself, it will only show that special skin type). Try this to show the special page only to non-members: <pre><code>if (!$member->isLoggedIn()) {
263         selectSpecialSkinType('login');
264 }</code></pre> or this to show the special skin type only for the main page: <pre><code>if (empty($blogid) && empty($catid) && empty($itemid)&& empty($archive) && empty($archivelist) && empty($special)) {
265         selectSpecialSkinType('welcome');
266 }</code></pre></td>
267 </tr></table>
268
269 <p>
270 Make sure that these methods are called <strong>after</strong> the <code>include('./config.php')</code> statement, and <strong>before</strong> the <code>selector();</code> statement!
271 </p>
272
273 <h2>Creating a blog in a subdirectory</h2>
274
275 <p>The process for creating a blog in a subdirectory (<tt>http://yourhost.com/sub/</tt> where the main weblog is in <tt>http://yourhost.com/</tt>) is similar, with the only change that you'll need to replace <code>include('./config.php');</code> by <code>include('../config.php');</code></p>
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291 <h1>XHTML Support <a name="xhtml" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>
292
293 <p>
294 If you see tags like <code>&lt;br /&gt;</code> in the source code of your webpage, it's because the output of Nucleus <small>(except the things defined by templates and skins, of course)</small> is compliant to the XHTML 1.0 standard from the W3C, which is the successor of HTML 4. This way, Nucleus is ready for the future of the web. As far as I know, this XHTML support does not cause any trouble with older browsers and is correctly interpreted.
295 </p>
296
297 <p>
298 What this means, is that you can perfectly create an XHTML-compliant site by using correct skins and templates. The default Nucleus skin is XHTML-compliant, but uses the "HTML 4 Loose" doctype. This way, users not knowing XHTML can not create documents with a false XHTML doctype.
299 </p>
300
301
302
303
304
305
306
307
308
309
310
311 <h1>How to create a Special skin part <a name="specialskinpart" href="#top" class="toplink"><img src="icon-up.gif" width="15" height="15" alt="back to top" /></a></h1>
312
313 <p>1. Enter the Nucleus admin area and go to Skins management page (<strong>Layout>Skins</strong>). Find your skin and click the Edit link in the right column.</p>
314
315 <p>2. Under the list of skin parts there is a sections called Special skin parts. In the field type the name of your special skin part and then click the Create button. (I'm using the name 'About' for my example). You then get a Edit skin part form, just like for any other skin part, that you can add content, skin variables or anything else. If you want to make it look like the rest of your site, you can copy the contents of the Main Index skinpart here and replace the <code>&lt;%body(...)%&gt;</code> skin variable with the contents of the static page.<br />
316 <br />
317 For example, using the default skin, the contents of the About skin part would look something like this:</p>
318 <pre><code>&lt;%parsedinclude(head.inc)%&gt;
319
320 &lt;!-- page header --&gt;
321 &lt;%parsedinclude(header.inc)%&gt;
322
323 &lt;!-- page content --&gt;
324 &lt;div id="container"&gt;
325 &lt;div class="content"&gt;
326 This site is run by a group of friends who all enjoy hiking. Together we have
327 hiked a total of over 4000 miles though out the US, Canada and Europe. Here we
328 share our experiences and our experience. Though we are serious hikers, we
329 believe hiking should first be fun for everybody.
330 &lt;br /&gt;&lt;br /&gt;
331 To join our community, please register here: (...link to registration page...)
332 &lt;br /&gt;&lt;br /&gt;
333 ... insert links to images of hiking fun...
334 &lt;/div&gt;
335 &lt;/div&gt;
336
337 &lt;!-- page menu --&gt;
338 &lt;h2 class="hidden"&gt;Sidebar&lt;/h2&gt;
339 &lt;div id="sidebarcontainer"&gt;
340 &lt;%parsedinclude(sidebar.inc)%&gt;
341 &lt;/div&gt;
342
343 &lt;!-- page footer --&gt;
344 &lt;%parsedinclude(footer.inc)%&gt;</code></pre>
345
346 <p>3. Now to access this page, you would point your browser (or put a link in your skin somewhere) to </p>
347
348 <pre><code>www.yourdomain.tld/index.php?special=About</code></pre>
349
350
351 <p>4. You can edit this skin part just as you would any other skin part and most skin variables and plugins will probably work.</p>
352
353 <p><strong>Note:</strong> You may want to keep your static content in a file called <code>About.html</code> in the <code>skins/default/</code> directory (if using the default skin) and instead of typing the content of the page in the skin part, just put <code>&lt;%include(About.html)%&gt;</code>. There's almost no restriction on what these pages can contain.</p>
354
355 <p>(Tip from  <a href="http://revcetera.com/ftruscot">ftruscot</a>)</p>
356
357 </body>
358 </html>