Customizing T3blog
Number of Views
To keep the number of views as realistic as possible, we should exclude at least our indexing engine, e.g., Mnogosearch. We can do that with an extra TypoScript definition and a small change in the function checkRiseViewNumber() that can be found in
/ext/t3blog/pi1/widgets/blogList/class.singleFunctions.php.
Add the following code after the if statement that checkes if user is loggen in the BE and before the cookies are checked.
PHP
- if (t3lib_div::cmpIPv4(t3lib_div::getIndpEnv(REMOTE_ADDR), $this->conf['ignoreIP_list'])) {
- return $rise;
- }
if (t3lib_div::cmpIPv4(t3lib_div::getIndpEnv(REMOTE_ADDR), $this->conf['ignoreIP_list'])) { return $rise; }
Now, we can define a list of IP's that should be ignored in the setup of the T3blog:
plugin.tx_t3blog_pi1.blogList.ignoreIP_list = 127.0.0.1, 192.168.0.1
Next, we have to disable caching for the "Single View" of the blog post, otherwise only cliks that put the page into cache will be counted for.
Counting our readers has its price that shows in page loading times. If we don't mind that readers see "old" numbers in the list view, we could store entry page of our blog in cache. What exactly "old" means depends on your cache configuration. To allow caching add following TypoScript.
Be aware, that now you should refresh your cache for Blog page when you update or add an entry! You can find how this can be done quite easy with your favorite browser on Wikipedia's Baypass your Cache article.
TypoScript
- [globalVar = GP:tx_t3blog_pi1|blogList|showUid > 0]
- config.no_cache = 1
- [end]
- plugin.tx_t3blog_pi1.blogList {
- requiredFields = commentauthor, commenttext, commentauthoremail, commenttitle, captcha
- }
[globalVar = GP:tx_t3blog_pi1|blogList|showUid > 0] config.no_cache = 1 [end] plugin.tx_t3blog_pi1.blogList { requiredFields = commentauthor, commenttext, commentauthoremail, commenttitle, captcha }
Comments
Checking syntax of the fields will return an error if you omit any of the following fields:
- author,
- title,
- author e-mail,
- author web site, and
- commenttext.
This is hardcoded in PHP function validateCommentSubmission that can be found in
typo3conf/ext/t3blog/pi1/widgets/blogList/class.singleFunctions.php.
We did not want to bother our readers with their web site address, so we commented out the commentauthorwebsite check in the $testData. Additionally, you have to define that this field is not required. We use:
PHP
- plugin.tx_t3blog_pi1.blogList {
- requiredFields = commentauthor, commenttext, commentauthoremail, commenttitle, captcha
- }
plugin.tx_t3blog_pi1.blogList { requiredFields = commentauthor, commenttext, commentauthoremail, commenttitle, captcha }
To submit a form in T3blog configuration where it does not generate the whole page, e.g., it is used as content element, you should disable caching during the submit with folowing TypoScript Setup:
TypoScript
- [globalVar = GP:tx_t3blog_pi1|blogList|insert = 1]
- config.no_cache = 1
- [end]
[globalVar = GP:tx_t3blog_pi1|blogList|insert = 1] config.no_cache = 1 [end]
Localization
At first we were planning to extend the t3blog with multilanguage support, but with a twist. Since it is unrealistic that we would write single blog post in more than one language, we were planning to provide articles in all languages at Slovenian pages. All technical posts would be in English languge, which is not a problem for most of the Slovenian visitors. English speaking visitor would get only English texts. After first version of the extention upgrade, which was based on post from zBlog, we noticed that this is probably unnecessary. Most of the elements can be translated without any changes in PHP code, which would limit our upgrade options and introduce some additional effort at the time of publication. So, we decided that English speaking visitors just won't follow links with titles in Slovenian :-) If you believe that this is problematic, do write a comment and tell us about it.
References:
Linking to selected posts
Linking to your posts from other content elements at your web page can be handled with some additional configuration of the linkhandler. We are using RTE editor tynimce and it's Typo3Link functionality, but linkhandler configuration should work with other editors, too. Please report your success in comments.
Add following setup in the page TS of the root page. In the provided example, 41 is the UID of the page with blog posts. If you have multiple blogs, you should configure linkhandler for every blog.
TypoScript
- #RTE.default.tx_linkhandler is used for RTE linkbrowser
- RTE.default.linkhandler {
- tx_t3blog_post {
- 41 {
- #storage folder
- parameter = 41
- select = uid,title as header,hidden
- sorting = crdate desc
- }
- }
- tx_t3blog_cat {
- 41 {
- #storage folder
- parameter = 41
- select = uid,catname as header,hidden
- sorting = crdate desc
- }
- }
- }
- #mod.tx_linkhandler is used for normal linkbrowser
- mod.tx_linkhandler {
- tx_t3blog_post {
- label=Blog-zapisi
- listTables=tx_t3blog_post
- onlyPids=41
- }
- tx_t3blog_cat {
- label=Blog-kategorije
- listTables=tx_t3blog_cat
- onlyPids=41
- }
- }
#RTE.default.tx_linkhandler is used for RTE linkbrowser RTE.default.linkhandler { tx_t3blog_post { 41 { #storage folder parameter = 41 select = uid,title as header,hidden sorting = crdate desc } } tx_t3blog_cat { 41 { #storage folder parameter = 41 select = uid,catname as header,hidden sorting = crdate desc } } } #mod.tx_linkhandler is used for normal linkbrowser mod.tx_linkhandler { tx_t3blog_post { label=Blog-zapisi listTables=tx_t3blog_post onlyPids=41 } tx_t3blog_cat { label=Blog-kategorije listTables=tx_t3blog_cat onlyPids=41 } }
For linkgeneration in the FE add following TS code to the Setup field of blog template.
TypoScript
- plugin.tx_linkhandler {
- tx_t3blog_post {
- forceLink = 0
- parameter = 43
- additionalParams = &tx_t3blog_pi1[blogList][showUidPerma]={field:uid}
- additionalParams.insertData = 1
- useCacheHash = 1
- }
- tx_t3blog_cat {
- forceLink = 0
- parameter = 43
- additionalParams = &tx_t3blog_pi1[blogList][category]={field:uid}
- additionalParams.insertData = 1
- useCacheHash = 1
- }
- }
plugin.tx_linkhandler { tx_t3blog_post { forceLink = 0 parameter = 43 additionalParams = &tx_t3blog_pi1[blogList][showUidPerma]={field:uid} additionalParams.insertData = 1 useCacheHash = 1 } tx_t3blog_cat { forceLink = 0 parameter = 43 additionalParams = &tx_t3blog_pi1[blogList][category]={field:uid} additionalParams.insertData = 1 useCacheHash = 1 } }
Couple of examples:
- link to the post "Mnogosearch optimization Example" which includes tips for t3blog,
- link to the category "Typo3".
Archive
To list only years that acctually have blog posts, small change in class.archive.php is neccessary. The added condition is market with comment.
PHP
- /**
- * Creates the content from collected post information through years.
- *
- * @return string
- */
- protected function assembleContent() {
- $content = '';
- if (count($this->years) > 0) {
- foreach ($this->years as $year => $row) { //wrap year li
- $dataCatLinkYear = array(
- 'text' => $year,
- 'datefrom' => $this->getMonthStart(1, $year),
- 'dateto' => $this->getMonthEnd(12, $year),
- 'entries' => $row['entries'],
- 'id' => $year
- );
- $dataYearLi = array(
- 'class' => 'year',
- 'text' => t3blog_div::getSingle($dataCatLinkYear, 'catLink', $this->conf) . $row['data']
- );
- /* Bostjan, 2011.04.12 */
- if ($dataCatLinkYear['entries'] > 0) {
- $yearsInArchive .= t3blog_div::getSingle($dataYearLi, 'itemWrap', $this->conf);
- }
- /*** end ******************/
- }
- $dataYearUl = array(
- 'class' => 'archive',
- 'text' => $yearsInArchive
- );
- $content = t3blog_div::getSingle($dataYearUl, 'listWrap', $this->conf);
- $content = t3blog_div::getSingle(
- array(
- 'categoryTree' => $content,
- 'title' => $this->pi_getLL('title')
- ), 'globalWrap', $this->conf
- );
- }
- return $content;
- }
/** * Creates the content from collected post information through years. * * @return string */ protected function assembleContent() { $content = ''; if (count($this->years) > 0) { foreach ($this->years as $year => $row) { //wrap year li $dataCatLinkYear = array( 'text' => $year, 'datefrom' => $this->getMonthStart(1, $year), 'dateto' => $this->getMonthEnd(12, $year), 'entries' => $row['entries'], 'id' => $year ); $dataYearLi = array( 'class' => 'year', 'text' => t3blog_div::getSingle($dataCatLinkYear, 'catLink', $this->conf) . $row['data'] ); /* Bostjan, 2011.04.12 */ if ($dataCatLinkYear['entries'] > 0) { $yearsInArchive .= t3blog_div::getSingle($dataYearLi, 'itemWrap', $this->conf); } /*** end ******************/ } $dataYearUl = array( 'class' => 'archive', 'text' => $yearsInArchive ); $content = t3blog_div::getSingle($dataYearUl, 'listWrap', $this->conf); $content = t3blog_div::getSingle( array( 'categoryTree' => $content, 'title' => $this->pi_getLL('title') ), 'globalWrap', $this->conf ); } return $content; }
« | October 2024 | » | ||||
---|---|---|---|---|---|---|
S | M | T | W | T | F | S |
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Latest Posts
This is hot
Categories
- Izobraževanje (13)
- Jadranje (0)
- Modelarstvo (0)
- Radioamaterstvo (0)
- Raziskave (1)
- Razno (5)
- Tehnika (2)
- Typo3 (3)
- Univerza (3)