[ABD] Topic Preview 0.5.4

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
benyboi
Registered User
Posts: 203
Joined: Thu Mar 01, 2007 6:50 pm

Re: [BETA] Topic Preview 0.5.4

Post by benyboi »

Cleori wrote:Hello,

may I ask a simple thing?

I've tried to install this mod, on my local copy of forum, and doesn't worked...

Neither prosilver, nor etech, a subsilver based style, because in its template folder, in its file ucp_prefs_view.html there is not the correct section to use "find" of the install.xml...

I'm wondering if possible to obtain the correct installation, but I'm wondering another thing:

In your opinion, it's possible to use the preview, generated by this MOD, in the way we used the old MOD "Advanced Hover Preview"?

I remember this old MOD using the "title" tag of the link of the topic, to show the preview text.

And I notice that in prosilver-->template-->viewforum_body.html we have the <dt style=..... {topicrow.TOPIC_FOLDER_IMG_ALT}...

in subsilver-->template-->viewforum_body.html we have <a title="{L_POSTED}:{topicrow.FIRST_POST_TIME}"...

I think the bolded variables can be replaced both by {topicrow.FIRST_POST_RESULT}, that should be the preview text generated by this MOD...

In this way we haven't to add any file to template folders, I think...

Someone interested to work on it too?

Thank you
That made no effing sence.

The mod works on prosilver and subsilver styles (i have used both) so you obviously didnt install it corrently.

Cleori
Registered User
Posts: 61
Joined: Tue Jul 03, 2007 10:33 pm

Re: [BETA] Topic Preview 0.5.4

Post by Cleori »

benyboi wrote:
That made no effing sence.

The mod works on prosilver and subsilver styles (i have used both) so you obviously didnt install it corrently.
The sence is making it easier...

However, if you install it and works... I'll try another time ...

Anyway: what change do you make at subsilver2-->template-->ucp_prefs_view.html?

And where do you apply changes at subsilver-->template-->viewforum_body.html (there are two <hr /> tags... should I use 1st, 2nd, or both? ) ?

Thank you

Cleori
Registered User
Posts: 61
Joined: Tue Jul 03, 2007 10:33 pm

Re: [BETA] Topic Preview 0.5.4

Post by Cleori »

I've tried again to install this mod:

PROSILVER--> Mod works, BUT NOT FOR ALL TOPICS... in viewforum.php page: some topic title shows preview... some other DON'T

SUBSILVER-LIKE style--> MOD DOESN'T work. Viewforum.php has a parse error:
1st time it was:

Code: Select all

Parse error: parse error in c:\program files\easyphp1-8\www\forum2\includes\template.php(175) : eval()'d code on line 58
second time it was

Code: Select all

Parse error: parse error in c:\program files\easyphp1-8\www\forum2\cache\tpl_etech_viewforum_body.html.php on line 58
And... YES, cache was empty, before this, I've done purge cache, as well as TEMPLATE REFRESH in ACP-->Styles

Just to laugh.. I've tried MY idea, putting {topicrow.FIRST_POST_RESULT} where I said, in viewforum_body.html of subsilver-like style... IT WORKED, I see preview instead of "Posted : Jan 14th, 2008", and for ALL TOPICS... unfortunately it's only one line, few characters, but... there is.

EDIT: No more Parse error--> was because of that ENDIF--> in instructions, instead of ENDIF -->

Still there is NOT the expected text in preview, for etech template (like subsilver), but "posted : Jan 14th, 2008"

EDIT2: I think this should be an error: when instructions say FIND <!-- BEGIN topicrow --> the following instruction should be BEFORE-ADD, not AFTER-ADD, otherwise it inserts the topic_preview.html EVERY ROW

clight77
Registered User
Posts: 907
Joined: Sun May 11, 2003 11:09 pm

Re: [BETA] Topic Preview 0.5.4

Post by clight77 »

Hi :)

I have problems with amount of text showing in box, i have it set for 250 but some posts show 1000 plus text.
I thought i seen this question 8 months back but i cannot find it.

For me to get text to show and not the "..." i had to use this in viewforum.php

//------------------------- Topic Preview
if ($config['topic_preview_enabled'] != 0)
{
$first_post = $posttext[$topic_id];
$first_post = preg_replace('/\[.+:.+\]/iU', '', $first_post);
$first_post = preg_replace('/<!-- s(.+?) -->.*?<!-- s\1 -->/i', '$1', $first_post);
$first_post = preg_replace('/<!-- (.+?) -->.*?<!-- \1 -->/i', '', $first_post);
$first_post = strip_tags($first_post);

$pad = ((substr_count($first_post, '"') + substr_count($first_post, "\n")) * 5) + substr_count($first_post, '\'');
$char_limit = $config['topic_preview_char_limit'] - intval($pad);
if (strlen($first_post) > $char_limit)
{
$first_post = substr($first_post, 0, $char_limit - 3) . "...";
}
$first_post = str_replace("\n", '<br />', $first_post);
$first_post = str_replace(array('"','\''), array('"', '\\\''), $first_post);
$esc_forum_name = str_replace(array('"','\''), array('"', '\\\''), $row['forum_name']);
}
//----------------------- Topic Preview


From srx or something like that :(

Thanks :)
I Follow Up On My Posts.
So Should Everybody...

User avatar
Sr X
Registered User
Posts: 202
Joined: Wed Feb 07, 2007 9:25 am

Re: [BETA] Topic Preview 0.5.3

Post by Sr X »

Cleori wrote:(...)PROSILVER--> Mod works, BUT NOT FOR ALL TOPICS... in viewforum.php page: some topic title shows preview... some other DON'T(...)
clight77 wrote:I have problems with amount of text showing in box, i have it set for 250 but some posts show 1000 plus text. (...)
i have the same problems that clight77 and Cleori
pgarvin76 wrote:
Sr X wrote:i have phpbb3 gold and work (with little problems) but because i know that the install.xml has any errors.
i think that the better is wait to the next version
Sr X can you elaborate on that is wrong with the install.xml (besides the CDATA thing). I can not get this to work on my phpBB3 Gold board. I've check and double checked and everything is installed correctly according to install.xml. It's really annoying me.
yes, install.txt

Cleori
Registered User
Posts: 61
Joined: Tue Jul 03, 2007 10:33 pm

Re: [BETA] Topic Preview 0.5.4

Post by Cleori »

If you talking about me... my instal is like your second code box...

just the number of char, is not set to 300-intval($pad), but like original one...

And I think however better replace /n with a space, rather than a <br /> tag...

In my forum I've a section with soccer-like team... one row=6 char average... one post preview... more than 20 or 30 rows...

BUT, I'm still on the 1st issue... IT DOES NOT WORK...

In prosilver NOT ALL topics have preview working (but ALL have preview code in source)

IN Subsilver there is not the way to edit ucp_prefs_view.html... I'm still trying..., for some reason this blocks the insertion of code in viewforum_body.html (cannot edit preferences in UCP)

Cleori
Registered User
Posts: 61
Joined: Tue Jul 03, 2007 10:33 pm

Re: [BETA] Topic Preview 0.5.4

Post by Cleori »

Let's resolve one problem at a time:

Prosilver doesn't show ALL previews, just some.

I notice that, in html generated, some calls to show_preview function have a "return" (ASCII LF=10 ) in text... they appear like:

Code: Select all

onmouseover="show_preview('','Prima o poi migrerò il forum alla versione PHPBB 3.0
<br />
<br />Prima ovviamente me la studio un po\'.
<br />
<br />Intanto se volete dare un\'occhiata agli stili per ora disponibili, li trovate sui siti:
<br />
<br />
<br />
<br />
<br />
<br />O cercando su google "styles phpbb 3.0"')"
And this preview DOESN'T work

If I edit html generated file like:

Code: Select all

onmouseover="show_preview('','Prima o poi migrerò il forum alla versione PHPBB 3.0<br /><br />Prima ovviamente me la studio un po\'.<br /><br />Intanto se volete dare un\'occhiata agli stili per ora disponibili, li trovate sui siti:<br /><br /><br /><br /><br /><br />O cercando su google "styles phpbb 3.0"')"
THIS WORKS, this shows preview...

EDIT:

GOTCHA!!!

Don't ask WHY, but for me worked this:

In viewforum.php:

The after-add section instead of:

Code: Select all

//------------------------- Topic Preview
                if ($topic_preview != 'false')
                {
                        $first_post = $posttext[$topic_id];
                        $first_post = preg_replace('/\[.+:.+\]/iU', '', $first_post);
                        $first_post = preg_replace('/<!-- s(.+?) -->.*?<!-- s\1 -->/i', '$1', $first_post);
                        $first_post = preg_replace('/<!-- (.+?) -->.*?<!-- \1 -->/i', '', $first_post);
                        $first_post = strip_tags($first_post);

                        $pad = ((substr_count($first_post, '"') + substr_count($first_post, "\n")) * 5) + substr_count($first_post, '\'');
                        $char_limit = $config['topic_preview_char_limit'] - intval($pad);
                        if (strlen($first_post) > $char_limit)
                        {
                                $first_post = substr($first_post, 0, $char_limit - 3) . "...";
                        }
                        $first_post = str_replace("\n", '<br />', $first_post);
                        $first_post = str_replace(array('"','\''), array('"', '\\\''), $first_post);
			$first_post = censor_text($first_post);
                        $esc_forum_name = str_replace(array('"','\''), array('"', '\\\''), $row['forum_name']);
                }
//----------------------- Topic Preview
Should be:

Code: Select all

//------------------------- Topic Preview
                if ($topic_preview != 'false')
                {
                        $first_post = $posttext[$topic_id];
                        $first_post = preg_replace('/\[.+:.+\]/iU', '', $first_post);
                        $first_post = preg_replace('/<!-- s(.+?) -->.*?<!-- s\1 -->/i', '$1', $first_post);
                        $first_post = preg_replace('/<!-- (.+?) -->.*?<!-- \1 -->/i', '', $first_post);
                        $first_post = strip_tags($first_post);

                        $pad = ((substr_count($first_post, '"') + substr_count($first_post, "\n")) * 5) + substr_count($first_post, '\'');
                        $char_limit = $config['topic_preview_char_limit'] - intval($pad);
                        if (strlen($first_post) > $char_limit)
                        {
                                $first_post = substr($first_post, 0, $char_limit - 3) . "...";
                        }
                        $expr = array("/\n/","/\r/" );
			$first_post = preg_replace($expr, '<br>', $first_post);
                        $first_post = str_replace('<br><br>", '<br>', $first_post);
                        $first_post = str_replace(array('"','\''), array('"', '\\\''), $first_post);
			$first_post = censor_text($first_post);
                        $esc_forum_name = str_replace(array('"','\''), array('"', '\\\''), $row['forum_name']);
                }
//----------------------- Topic Preview

Cleori
Registered User
Posts: 61
Joined: Tue Jul 03, 2007 10:33 pm

Re: [BETA] Topic Preview 0.5.4

Post by Cleori »

benyboi wrote:
That made no effing sence.

The mod works on prosilver and subsilver styles (i have used both) so you obviously didnt install it corrently.
After hours of trials... I have to answer...

MOD, exactly how linked in 1st message, CAN'T work for subsilver.

There IS NOT a topic_preview.html for that style, and the one included is MISMATCHING.

It displays the preview text floating over topic rows, without any formatting.

I'm pretty sure that css codes must be included in same file topic_preview.html to display something

OR

topic_preview.html must be rewritten, in the last part, according with the format of the style

I'll work on it later or tomorrow...

Thank you

fryed_1
Registered User
Posts: 64
Joined: Fri Oct 19, 2007 6:04 pm

Re: [BETA] Topic Preview 0.5.4

Post by fryed_1 »

Sr X wrote:Code install.xml needs to be fixed because it have not the attribute <! [CDATA [...]]>

Code: Select all

<! [CDATA [... code word, PHP, etc. ...]]> 
for this many users install this mod wrong.

one question, how set the mod to that the default user option will be "enable topic preview"?
thanks.
I'll work on enabling it by default. I had thought it was though.

fryed_1
Registered User
Posts: 64
Joined: Fri Oct 19, 2007 6:04 pm

Re: [BETA] Topic Preview 0.5.4

Post by fryed_1 »

*Capmaster* wrote:
Dead link.
Yeah test site is out of commission right now. I'll work on getting it back up later this week.

fryed_1
Registered User
Posts: 64
Joined: Fri Oct 19, 2007 6:04 pm

Re: [BETA] Topic Preview 0.5.4

Post by fryed_1 »

Sr X wrote:is possible set this mod from ACP to that this mod work only in any forums and not in all forums? (difficult true?) uhmmm so perhaps this do less queries... :?:
So like a setting in forum permissions to enable/disable the mod for specific forums? I suppose I can add it eventually.

fryed_1
Registered User
Posts: 64
Joined: Fri Oct 19, 2007 6:04 pm

Re: [BETA] Topic Preview 0.5.4

Post by fryed_1 »

Geisthund wrote:Hi

Could you mod this mod to show previews in search results eg http://www.phpbb.com/community/search.p ... ive_topics

Cheers
Gareth
On the main page, it shows that I am working on it for search results.



For everyone else... sorry I haven't been around working on this more. New baby in the house really limits my time, but I'll try to plug away at it and get everything up to par soon.

Cleori
Registered User
Posts: 61
Joined: Tue Jul 03, 2007 10:33 pm

Re: [BETA] Topic Preview 0.5.4

Post by Cleori »

fryed_1 wrote: On the main page, it shows that I am working on it for search results.



For everyone else... sorry I haven't been around working on this more. New baby in the house really limits my time, but I'll try to plug away at it and get everything up to par soon.
No problem, mate, I've got a new baby too... I understand you PERFECTLY :mrgreen:

Anyway... I'm gone on with your work, finding some things to do, interesting, in my humbling opinion...

I've done these thing for my board...
1) Topic_preview.html now is included only one time in viewtopic_body.html
2) Make a little mod to viewforum.php editing, so that CR/LF are correctly substituted
3) Adapted topic_preview.html to styles like subsilver (these styles haven't the same css classes as prosilver)

If you want I'll be happy to share it with you, send me your e-mail via PM, and I'll send you my zip file...

Thank you.
Bye

EDIT: Another little question: what's the use of
$esc_forum_name = str_replace(array('"','\''), array('"', '\\\''), $row['forum_name']);
in viewforum_body.html?

I ask this because debug says : undefined variable forum_name
EDIT2: If user sets enable preview=NO, then the variable $first_post results UNDEFINED
could be better add

Code: Select all

} else {
$first_post="";
}
in viewforum.php, in this section:

Code: Select all

<find> $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ?
        append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' .
        (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') .
        "&amp;t=$topic_id", true, $user->session_id) : '';</find>

        <action type="after-add">
//------------------------- Topic Preview
                if ($topic_preview != 'false')
                {
                        $first_post = $posttext[$topic_id];
                        $first_post = preg_replace('/\[.+:.+\]/iU', '', $first_post);
                        $first_post = preg_replace('/<!-- s(.+?) -->.*?<!-- s\1 -->/i', '$1', $first_post);
                        $first_post = preg_replace('/<!-- (.+?) -->.*?<!-- \1 -->/i', '', $first_post);
                        $first_post = strip_tags($first_post);

                        $pad = ((substr_count($first_post, '"') + substr_count($first_post, "\n")) * 5) + substr_count($first_post, '\'');
                        $char_limit = $config['topic_preview_char_limit'] - intval($pad);
                        if (strlen($first_post) > $char_limit)
                        {
                                $first_post = substr($first_post, 0, $char_limit - 3) . "...";
                        }
                        $expr = array("/\n/","/\r/" );
						$first_post = preg_replace($expr, '<br>', $first_post);
                        $first_post = str_replace('<br><br>', '<br>', $first_post);
                        $first_post = str_replace(array('"','\''), array('"', '\\\''), $first_post);
			$first_post = censor_text($first_post);
                        //$esc_forum_name = str_replace(array('"','\''), array('"', '\\\''), $row['forum_name']);
   // Cleori edit: commented above because debug says "undefined: forum_name"
                        } else {
				$first_post="";
			}
//----------------------- Topic Preview
        </action>
FINAL EDIT: For those who cares: HERE is my own editing of the MOD. Hope it helps. Bye

pgarvin76
Registered User
Posts: 136
Joined: Sun Mar 20, 2005 5:33 am
Location: Philadelphia, USA
Contact:

Re: [BETA] Topic Preview 0.5.4

Post by pgarvin76 »

Thanks to SrX and Cleori I finally got this working!

Cleori:
Instead of:

Code: Select all

$expr = array("/\n/","/\r/" );
                  $first_post = preg_replace($expr, '<br>', $first_post);
You can use the simpler str_replace:

Code: Select all

$first_post = str_replace(array("\r\n","\n","\r"), '<br />', $first_post);
Notice I am also searching for \r\n together first, so that \r\n doesn't get substituted by 2 br's. Got the idea from php.net documentation.

fryed_1: I don't see why:

Code: Select all

$pad = ((substr_count($first_post, '"') + substr_count($first_post, "\n")) * 5) + substr_count($first_post, '\'');
is needed. You are accounting for the escaping of double quotes and slashes. But the escaping \ isn't in the string yet. And why the times 5 for new lines?

Cleori
Registered User
Posts: 61
Joined: Tue Jul 03, 2007 10:33 pm

Re: [BETA] Topic Preview 0.5.4

Post by Cleori »

pgarvin76 wrote:Thanks to SrX and Cleori I finally got this working!

Cleori:
Instead of:

Code: Select all

$expr = array("/\n/","/\r/" );
                  $first_post = preg_replace($expr, '<br>', $first_post);
You can use the simpler str_replace:

Code: Select all

$first_post = str_replace(array("\r\n","\n","\r"), '<br />', $first_post);
Notice I am also searching for \r\n together first, so that \r\n doesn't get substituted by 2 br's. Got the idea from php.net documentation.
Great, I'll try it immediately ;)

Thank you

EDIT: It works very well.. :mrgreen:

EDIT 2: If I leave the $first_post = str_replace('<br><br>', '<br>', $first_post);, after row you suggested ,the preview - IMHO - is even better ;)

Locked

Return to “[3.0.x] Abandoned MODs”