[TYPO3-timtab] comments, pagination, ve_guestbook, timtab....
Tyler Kraft
headhunterxiii at yahoo.ca
Wed Jun 14 18:46:54 CEST 2006
A vexing issue....
Background: see post "Comments problem"
So the problem is that we need to have pagination for blog comments. Its
not really feasible to tell our clients "No sorry it can't be done, you
just need to have a page with all the comments on it - even if it is
100, or 1000 or even 1 million entries" At least my clients won't be
happy about this or really accept it. So what do we do... Well
ve_guestbook has the ability to paginate the comments! Perfect we think! 8-)
So we wonder why the comment pagination isn't working for blog
comment... OH-NO problem... the pagination isn't in any of the templates
or in any of the themes for timtab. That's why it doesn't work. So we
copy it out of the ve_guestbook template and put into the blog theme
template! All of a sudden pagination works, and we can configure it for
the comments via the typoscript object browser. Great we're happy
again... 8-)
But then when we try to use it there's a big problem - when we click to
go to the next page we get the next 'X' number of comments but no post,
just the "no new_id given" message. And what's worse is that its showing
all the blog comments all of a sudden! Well that's no good. Why -
because the pagination links don't include the get variables for day,
month, year, and news_id, that were in the first page. So ve_guestbook
doesn't have any idea what blog post to show or which comments as it
can't associate any with the current posting (because there isn't one).
So to get this to work we need a tiny bit of php in an include script
(which relies on a little bit of internal T3 magic and a preg_replace),
some minor typoscript and markers in the right template - and volia it
works!
Heroes what we do:
1) make sure we copy the markers out of the original ve_guestbook
template and put them into the relevant ve_guestbook template for our
theme. The should go into the TEMPLATE_LIST section.
The markers are ###LINK_PREV### ###PAGES### ###LINK_NEXT### and
obviously as its just like templating anything we can put any old html
we want around there also.
2) include our little bit of php as a function in an include file:
<?php
function user_addTtNewsVars($content){
$ttNews = t3lib_div::GPvar('tx_ttnews');
$year = $ttNews['year'];
$day = $ttNews['day'];
$month = $ttNews['month'];
$newsItem = $ttNews['tt_news'];
$addVar =
"&tx_ttnews[year]=$year&tx_ttnews[month]=$month&tx_ttnews[day]=$day&tx_ttnews[tt_news]=$newsItem";
$content = preg_replace('/(<a href="[^"]+)/', "$1$addVar", $content);
return $content;
}
?>
3) add the following lines of typoscript to our template:
page.10.marks.POSTS_LIST.limit = 1000
includeLibs.anything = fileadmin/path/filename.inc
plugin.tx_veguestbook_pi1.latestWithPagebrowser = 1 # might be needed ?
plugin.tx_veguestbook_pi1.pageBrowser{
page_stdWrap.postUserFunc = user_addTtNewsVars
next_stdWrap.postUserFunc = user_addTtNewsVars
previous_stdWrap.postUserFunc = user_addTtNewsVars
}
And now we are happy!
For the moment at least.... So I've just got this to work, so if there
are any glaring errors please mention them! Or if there are any places
we can improve it... I'm not including the cHash in the append variables
so if anyone could advise if it should be there or not that would be
helpful (mainly because I don't really understand the cHash and I'm not
sure if it should be included or not).
HTH
Tyler
More information about the TYPO3-project-timtab
mailing list