| Меню для TalkBack | Перевод документации |
|---|---|
| Скачать Языковой Файл RU |
|
Customizing TalkBack requires a basic knowledge of HTML and CSS. If you lack that knowledge, now is as good a time as any to learn. :-)
But I am not your HTML and CSS teacher...it’s up to you to do your homework and learn the basics. Please don’t ask me how to change the style of an element so that it has a different color, font size, etc. I don’t have the time or patience to provide that type of support. Instead do a web search for HTML or CSS and words like tutorial, tips, tricks. You might start with the W3C tutorials.
If you are using Microsoft’s Notepad as your text editor you should get a source code editor to use when viewing and changing CSS, HTML and PHP files. Such an editor will have code syntax hightlighting and other features that make the job of viewing and editing these file types easier.
A simple and free programmer’s editor is Notepad++. If you are not doing much work with CSS, HTML and PHP, this would be my choice.
Wikipedia has an article that has a list of of text editors and a simple comparison.
A web search for text editors and text editors comparison will yield a lot of information.
You should have Internet Explorer (IE6 and IE7), Firefox and Opera installed on your PC and view your changes with each of the browsers. Some style elements will yield different results on each browser and your pages may not look very good in a particular browser if you don’t tweak the styles.
After changing the stylesheet you should vaildate it at: http://jigsaw.w3.org/css-validator/ to catch any errors.
To find the name of a style you want to change, browse to the TalkBack test page http://yoursite.com/talkback/test.php. Enter a comment. Enter a reply to that comment. Copy some text from the rendered page of the element you want to change. Use your browser’s view source command to display the HTML source code. (Firefox: Ctrl+U, Internet Explorer: View menu > Source). Use the find command on the view source page to find that text. The style id or class name will be nearby.
my-styles.css (the file you created by copying style.css is the primary stylesheet for comments templates.
styleIE.css and styleOpera.css contain entries that override the primary styles for those browsers.
admin/admin.css contains styles for the admin panels. But a number of the admin scripts have override and supplemental styles inside a <style> tag so I don’t recommend trying to restyle the admin panels unless you have plenty of spare time.
I recommend you make at least some basic changes to match the appearance of your site. Such changes would include: comment and form widths, fonts, comment header background color, form background and border colors.
The best way to go about changing styles is to use your browser’s menu command to view your page source. That will show you the HTML stripped of all PHP making it relatively easy to pick out the CSS id and class names for each of the page’s HTML elements.
If you want to change a page layout, the templates of interest are:
Instead of changing the default templates, I recommend that you copy and rename the template. Doing so will ensure that changes you make will not be overwritten by future releases of TalkBack. Example: rename comments-display-tpl.php to my-comments-display-tpl.php
Instruct the system to use the different template by changing the template file name in the configuration settings.
Finally, document your changes. Write down in detail what you changed and keep the document in a safe place to refresh your memory in the future.
Yes, the templates do have some PHP code in them, but that code is not doing much more than printing (sending) HTML to your browser. So don’t let the PHP code scare you. Do not change the PHP code unless you know what you are doing. Though, you can move a block of code to a different location in the template if you want to rearrange the layout.
Below is short primer about the types of PHP statements you will see in the templates. The primer won’t turn you into a PHP programmer but it will give you insights that allow you to to separate the PHP code from the HTML code as you are viewing a template.
Print statement
Sends the text inside the double quotes to the browser. Example:
print " <!-- Language select links --> <p class='tb-center'>$language_links</p>";Your browser ignores indenting and extra spaces, and doesn't care whether or not multiple tags occur on the same line. But I have taken care to print the HTML in such a manner that if you view it with your browser’s view source commmand, it will be indented and easy to read.
PHP variables
A variable looks like this: $language_links or this $lang['comdisplay6']. The variable contains a value (a piece of information). Think of the variable name as a placeholder. When the script is executed PHP replaces the variable name with the actual contents of the variable.
Most variables in the templates were created by the driver script (the script that is executed just prior to the template script). But some come from the configuration table array $config['entryname'] or the language file array $lang['entryname']. PHP statements use the variables to either decide what action to take or to print the variable to the browser.
If statements
Determines whether or not an action is done, i.e if condition x do y. Example:
if ($x || $y) {
print "this text";
}
Means: if the variable $x has a value OR $y has a value, print to the browser whatever is inside the double quotes. May also be written as:
if ($x || $y) print "this text";You will also see if statements in this format:
if (condition 1) {
print "some text";
} elseif (condition 2) {
print "some different text";
} else {
print "the default text";
}
Note the use of the { and } characters. { marks the start of an action and } marks the end of an action. Like HTML, PHP code can be mashed together on one line. But I have used multiple lines and indentation to make the code easier to read.
For statements
Causes something to be done a number of times.
for($counter = 0; $counter < $some_number; $counter++) {
do something
}
Means: starting with $counter at zero, while $counter is less than the value in $some_number, do something then increment the counter by 1 and repeat the process.
Operators
== is equal to != is not equal to < is less than > is greater than || OR && AND = set the value of the variable on the left to the value of the variable or string on the right
Include statments
Causes another script file to be executed. Examples:
include "filename.php";Reads in and executes the file named filename.php.
include $config['comments_form_tpl'];Reads in and executes the file whose name is contained in the $config array entry. In this case, the filename is for the comments form template.
Rule number 1: Don’t open the templates in your editor and start scrolling through it much less cutting and pasting. Also important, don’t open a template or CSS file and throw up your hands in dispair, “Oh, it’s all so complicated.” Print the templates.
Rule number 2: browse to the TalkBack test page http://yoursite.com/talkback/test.php. Enter a comment. Enter a reply to that comment. Use your browser’s view source command to display the HTML source code. (Firefox: Ctrl+U, Internet Explorer: View menu > Source). This is the HTML code that the PHP code in the templates produces. Print the source code. It’s easier to work with on paper.
The template printout shows you the combination of PHP code and HTML code that creates the HTML source code that is sent to the browser. Study and compare the two printouts and the comments page on your monitor and you will more quickly grasp what the template is doing and where in the template you will be making your change.
Want to change the styling: colors, backgrounds, fonts, etc? Look at the browser source code printout. Find the HTML tag for the element you want to change. It will have either an “id” or a “class”. Look for the id or class in the CSS.
Trial and error are great teachers. Make a backup copy of a file before changing it and you can’t do any damage that can’t be easily undone.
Заданные по умолчанию стили дают простое отображение комментариев. Демонстрационная страница http://www.scripts.oldguy.us/talkback/demo/.
Там есть ссылка на слайдшоу, демонстрирующее альтернативные страницы tpl и стили CSS. Если Вы хотите использовать один из альтернативных стилей, Вы найдете файлы css и шаблоны tpl в talkback/addons/alternate-layouts. Каждый дополнительный стиль имеет файл помощи, readme.txt. Следуйте за командами в readme файле.
The default error message panel appears on a new page with a gray background. {example}
You can change it so that the error message page appears with your site layout. That is what I did on my scripts website. {example}
Create a new template named my-message-panel.php. Insert your page header, sidebar and footer HTML. Then copy the below code into the body section.
<?php
print "
<div id='tb-panel-content'>
<div id='tb-panel-message'>
<p>$display_message</p>
<p>$dberror</p>
<p>$footnote</p>
</div>
<div class='tb-panel-link'>$mc_link</div>
</div>";
exit();
?>
Copy #tb-panel-content, #tb-panel-message and .tb-panel-link from style.css to styleCustom.css and change them to suit your layout.
Finally, change the message panel file name in the admin configuration settings panel.
You can change it so that the preview panel appears with your site layout.
Create a new template named my-comments-preview-tpl.php. Insert your page header, sidebar and footer HTML. Then copy the below code into the template.
In the head section of the page:
<?php require 'head-inc.php'; $separator = ($display['form_location']) ? '–' : ''; ?>
In the body section of the page:
<?php
print "
<div id='tb-wrapper'>
<div class='tb-comment'>
<div class='tb-comment-header'>
<div class='tb-author-loc'>
<span class='tb-author'>{$display['form_author']}</span>
$separator
<span class='tb-location'>{$display['form_location']}</span>
</div>
</div>";
if ($config['comment_subject'])
// Show subject line
print "
<div class='tb-comment-subject'><span class='tb-subject-title'>{$lang['subject']}</span> {$display['form_subject']}</div>";
print "
<div class='tb-comment-text'>
{$display['form_textarea']}
</div>
</div>
<br /><br />";
if ($_REQUEST['action'] == 'update') {
require 'comments-edit-form-tpl.php';
} else {
include $config['comments_form_tpl'];
}
print "
</div> <!--end of tb-wrapper -->";
?>
Finally, change the preview panel file name in the admin configuration settings panel.
You can change it so that the reply panel appears with your site layout.
Create a new template named my-comments-reply-tpl.php. Insert your page header, sidebar and footer HTML. Then copy the below code into the template.
In the head section of the page:
<?php require 'head-inc.php'; $separator = ($location[0]) ? '–' : ''; ?>
In the body section of the page:
<?php
print "
<div id='tb-wrapper'>
<div id='ID-$tbid[0]' $comment_type_class[0]>
<div class='$header_class[0]'>
<div class='$author_loc_class[0]'>
<span class='$author_class[0]'>$author[0]</span>
$separator
<span class='$location_class[0]'>$location[0]</span>
</div>
<!-- <div class='$tbid_class[0]'> | #$tbid[0]</div> -->
<div class='$date_class[0]'>$time[0]</div>
</div>";
if ($config['comment_subject'])
// Show subject line
print "
<div class='tb-comment-subject'><span class='tb-subject-title'>{$lang['subject']}</span> $subject[0]</div>";
print "
<div class='tb-comment-text'>$text[0]</div>
</div>";
// +++++++++++++++++++++++++++++++++++++++++++++++
// Print the comments entry form
// +++++++++++++++++++++++++++++++++++++++++++++++
print "
<p class='tb-stress'>{$lang['reply_panel_legend']} {$author[0]}</p>";
require COMMENTS_FORM_TPL;
print "
</div> <!--end of tb-wrapper -->
?>
Finally, change the reply panel file name in the admin configuration settings panel.
Comment author email address is required so you cannot eliminate it but you can “force” it to be a particular value and hide the field on the comment form.
Copy comments-form-tpl.php to my-comments-form-tpl.php file. In the new file change:
<input class='tb-field' type='text' name='form_email' value =\"{$_REQUEST['form_email']}\" maxlength='70' />
<label class='tb-required'>*</label>
<label class='tb-label'>{$lang['comform4']}</label>";</code>
<input type='hidden' name='form_email' value ='nobody@nowhere.com' />In admin panels > maintenance menu > edit configuration settings:
Find .tb-credit in my-styles.css and add to it: display: none
A donation is required if you remove the link.
A configuration setting allows you to enable or disable emoticons in comments posts.
The emoticon image files are in images/smilies. You can substitute your own icons by replacing any file with a new file of the same name. You can also add and delete emoticons by editing /images/smilies/emoticons.inc. That file controls:
An explantion of the entries is at the top of emoticon.inc.
The language in which weekday and month names will be displayed is specified in the date_locale setting in the configuration maintenance panel.
If the locale is empty or invalid, the date will be displayed in your system’s default language (usually English). The TalkBack installer will set this field to be the same as the language you selected during installation. That language name may or may not be a valid locale code. So you may have to follow the below instructions to find a valid code for non-English languages.
You can tell if you have set the right code for your language by looking at the admin date and comments template date fields in the admin configuration maintenance panel.
The locale setting entry may be constructed as: a two character language code (en), a language code and country code combination (en_US or en_UK), a three character language code (eng), a language name (english).
Unix type operating systems use language names and codes from the ISO-639 specification. Windows server users see this MSDN website.
Some systems may require a language code/country code combination (en_US). Some may require that a character set identifier be appended (examples: en_US.ISO8859-1 or en_US.UTF-8).
You may need to do a little trial and error experimenting to get dates to display properly in your language. As an example, for the Dutch language, try entering each of the following into the TalkBack date locale setting until you find one that works:
dutch
dut
nl_NL
nld_NLD
nl_NL.UTF-8
nl_NL.ISO8859-1
nld_NLD.UTF-8
nld_NLD.ISO8859-1
If you are unable to find a string that works, contact your web host technical support and ask them if your language is installed and, if so, what PHP locale string to use for setting the locale.
The format of dates is specified by the admin_date (for admin panels) and comments_date (for comments templates) in the configuration maintenance panel. These settings contain a “format string” that is applied to dates. Examples:
%m/%d/%y - %H:%M Yields output like: 11/16/06 - 15:15%B %d, %Y - %H:%M Yields output like: November 16, 2006 - 15:16Not all parameters may be supported by your system, in which case they will not be supported by PHP function used by TalkBack. Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means, for example, %e, %T, %R and %D (there might be more) and dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems.
Для меня это все сложно, а хотелось бы поставить скрипт на сайт. Кто поможет?
Читаю что Вы пишете - дом 2 вспоминается :)
Это прям в точку!!! Другими словами и не скажешь! :)
Интересно. Вопрос только в том, как это будет выглядеть в будущем :)