Browse code

3.5.6 efiction version

Jimako authored on 2024/03/09 16:09:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,110 @@
1
+<html>
2
+
3
+<head>
4
+<meta http-equiv="Content-Language" content="en-us">
5
+<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
6
+<meta name="ProgId" content="FrontPage.Editor.Document">
7
+<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
8
+<title>Creating Blocks</title>
9
+</head>
10
+
11
+<body>
12
+
13
+<h2 align="center">Creating Blocks</h2>
14
+<p>For those that want to create their own blocks to share with others or just 
15
+  tweak the ones included already, here's the basics.&nbsp; There are two files 
16
+  needed for each block: blockname.php an init.php.&nbsp; Technically, if you 
17
+  added the block manually, you wouldn't need the init.php file.&nbsp; It is only 
18
+  used when the block is first initialized, and can be deleted afterward.&nbsp; 
19
+  Though I would suggest keeping a backup somewhere, just in case.</p>
20
+<p>The init.php file is very simple composed simply of a mysql statement that 
21
+  adds the block tot he database.&nbsp; As in the example below.</p>
22
+<p>&lt;?php<br>
23
+  dbquery(&quot;INSERT INTO &quot;.TABLEPREFIX.&quot;fanfiction_blocks(`block_name`, 
24
+  `block_title`, `block_status`, `block_file`, `block_variables`) VALUES('categories', 
25
+  'Main Categories', '0', 'categories/categories.php', '');&quot;);<br>
26
+  ?&gt;</p>
27
+<p>This also shows the basic parameters needed for a block: name, title, status, 
28
+  file, and variables.&nbsp; The title can be an empty string if you don't need 
29
+  a title for that particular block. If the block doesn't need any variables, 
30
+  that too can be left empty. The file should be a subfolder/file of the blocks 
31
+  folder for the sake of consistency. The status should generally start off as 
32
+  0 for inactive.&nbsp; There are 3 status options for blocks: </p>
33
+<div align="center">
34
+  <center>
35
+  <table border="1" cellpadding="5" cellspacing="0" 
36
+  style="border-collapse: collapse" bordercolor="#111111">
37
+    <tr>
38
+      <th colspan="2">Status</th>
39
+      <th>&nbsp;Associated .tpl file</th>
40
+      <th>Appears</th>
41
+    </tr>
42
+    <tr>
43
+      <td>0</td>
44
+      <td>Inactive</td>
45
+      <td>The block is off. </td>
46
+      <td>nowhere</td>
47
+    </tr>
48
+    <tr>
49
+      <td>1</td>
50
+      <td>Active</td>
51
+      <td>The block is on.</td>
52
+      <td>anywhere</td>
53
+    </tr>
54
+    <tr>
55
+      <td>2</td>
56
+      <td>Index only</td>
57
+      <td>index page only.</td>
58
+      <td>anywhere on the index page.</td>
59
+    </tr>
60
+    </table>
61
+  </center>
62
+</div>
63
+<p>&nbsp; </p>
64
+<p>Any default configuration you want for the block can be included in the init.php 
65
+  as well.&nbsp; The variables are an array encoded using PHP's serialize function. 
66
+  For instance, the categories block currently has two options: one column and 
67
+  multiple columns.&nbsp; The default is a single column lists.&nbsp; If I were 
68
+  to change the init file as follows, the default would then become a multiple 
69
+  column list.</p>
70
+<p>&lt;?php<br>
71
+  dbquery(&quot;INSERT INTO &quot;.TABLEPREFIX.&quot;fanfiction_blocks(`block_name`, 
72
+  `block_title`, `block_status`, `block_file`, `block_variables`) VALUES('categories', 
73
+  'Main Categories', '0', 'categories/categories.php', '&quot;.serialize(array(&quot;columns&quot; 
74
+  =&gt; &quot;1&quot;)).&quot;');&quot;);<br>
75
+  ?&gt;</p>
76
+<p> When you change any of the settings for the blocks from the admin panel the 
77
+  information stored in the database about the block is updated.</p>
78
+<p>The block.php file creates the content that is placed inside the {blockname_content} 
79
+variable.&nbsp; This content is placed inside a variable $content which is then 
80
+assigned to {blockname_content}&nbsp; So a very simple example of a block would 
81
+be:</p>
82
+<p>&lt;?php<br>
83
+$content = &quot;Hello World!&quot;;<br>
84
+?&gt;</p>
85
+<p>There are two other optional files.&nbsp; The first is an admin file which 
86
+will be called from the admin panel to make changes to the settings in the 
87
+block.&nbsp; Creating one of those is for another day. </p>
88
+<p>The second file (or multiple files) is a language file that defines any text 
89
+you use in your block.&nbsp; These files take the same format as the main 
90
+language file in the languages folder and are named similarly.&nbsp; So for 
91
+instance, an English language file would be named en.php.&nbsp; For Spanish, it 
92
+would be es.php. </p>
93
+<p>Most often, you might need to define some wording for your admin.php file.&nbsp; 
94
+If you need to add a language file, use the following code in either admin.php 
95
+or blockname.php</p>
96
+<p>if(file_exists(&quot;blocks/categories/{$language}.php&quot;)) include_once(&quot;blocks/categories/{$language}.php&quot;);</p>
97
+<p>The if(...) isn't technically necessary, but it will prevent errors if the 
98
+  file ends up missing.&nbsp; For instance, the site's language is set to Russian, 
99
+  but the block doesn't have a Russian translation.&nbsp; You might also want 
100
+  to include an else statement to load a default language file you have created 
101
+  if the site's chosen language is missing.</p>
102
+<p>if(file_exists(&quot;blocks/categories/{$language}.php&quot;)) include_once(&quot;blocks/categories/{$language}.php&quot;);<br>
103
+  else include_once(&quot;blocks/categories/en.php&quot;);</p>
104
+<p>To keep your block files secure from hackers you are strongly encouraged to 
105
+  include this line at the top of each file just under the &lt;?php</p>
106
+<p>if(!defined(&quot;_CHARSET&quot;)) exit( );</p>
107
+<p>&nbsp;</p>
108
+</body>
109
+
110
+</html>
0 111
\ No newline at end of file