e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
321 stars 213 forks source link

Post reply and list of 10 previous answers #4244

Open ericc-dream opened 3 years ago

ericc-dream commented 3 years ago

In the v1, in the template, we had 2 "variables" : $FORUMPOST and $FORUMPOST_REPLY The first one was used when creating a new thread and the second when replying to a thread The second had the benefit to be able to display the 10 last answers in reverse order ({LATESTPOSTS}) which was really interesting to reply correctly to some post and being able to copy some part to insert them as "quote" or "blockquote" into our message

Actually, in the v2, and as far as I can see, the variable $FORUM_POST_TEMPLATE['reply'] exist but despite all my effort doesn't seems to be used anymore And some part of {LATESTPOSTS} exist and can be activated by adding global $LATESTPOSTS_START, $LATESTPOSTS_POST, $LATESTPOSTS_END ; at the beginning of forum_post.php -> function getTemplate Then, if you add <div class='text-center'> {LATESTPOSTS} </div> at the end of the variable $FORUM_POST_TEMPLATE['form'], a table is printed but empty !! And it appear on all type of post, reply or create .

Is it possible to reactivate this very useful function ?

Thanks

ericc

tgtje commented 3 years ago

Just an observation. You are mentioning adding code in forum_post. But you want an outcome to be seen? > would be a view...php file. (templates or shortcode). If i misunderstand, sorry

ericc-dream commented 3 years ago

No problem On v1, in forum_post_template.php, we had :

if(!$FORUMPOST_REPLY)
{
$FORUMPOST_REPLY = " .... (all the page build as for $FORUMPOST) 
<div style='text-align:center'>
{THREADTOPIC}
{LATESTPOSTS}
</div>

if(!$LATESTPOSTS_START)
{
$LATESTPOSTS_START = "
<table style='".USER_WIDTH."' class='fborder'>
<tr>
<td colspan='2' class='fcaption' style='vertical-align:top'>".
LAN_101."{LATESTPOSTSCOUNT}".LAN_102."
</td>
</tr>";
}

if(!$LATESTPOSTS_POST)
{
$LATESTPOSTS_POST = "
<tr>
<td class='forumheader3' style='width:20%;vertical-align:top'><b>{POSTER}</b></td>
<td class='forumheader3' style='width:80%'>
    <div class='smallblacktext' style='text-align:right'>".IMAGE_post2." ".LAN_322."{THREADDATESTAMP}</div>
    {POST}
</td>
</tr>
";
}

if(!$LATESTPOSTS_END)
{
$LATESTPOSTS_END = "
</table>
";
}

and in forum_post_shortcodes.php :

/*
SC_BEGIN LATESTPOSTS
global $thread_info, $action, $gen, $tp, $forum_shortcodes, $post_info;
global $LATESTPOSTS_START, $LATESTPOSTS_END, $LATESTPOSTS_POST;
$txt = $tp->parseTemplate($LATESTPOSTS_START, TRUE, $forum_shortcodes);
for($i = count($thread_info)-2; $i>0; $i--)
{
    $post_info = $thread_info[$i];
    $txt .= $tp->parseTemplate($LATESTPOSTS_POST, TRUE, $forum_shortcodes);
}
$txt .= $tp->parseTemplate($LATESTPOSTS_END, TRUE, $forum_shortcodes);
return $txt;
SC_END

SC_BEGIN LATESTPOSTSCOUNT
  return;           // Null return as placeholder
SC_END
*/

in the v2, if you look into v2/e107_plugins/forum/shortcodes/batch/post_shortcodes.php, you can find

    function sc_latestposts($parm) //TODO  move elsewhere?
    {
        $parm = ($parm ? $parm : 10);
        global $LATESTPOSTS_START, $LATESTPOSTS_END, $LATESTPOSTS_POST;
        $tp = e107::getParser();
        $txt = $tp->parseTemplate($LATESTPOSTS_START, true);
        $start = max($this->threadInfo['thread_total_replies'] - $parm, 0);
        $num = min($this->threadInfo['thread_total_replies'], $parm);

        $tmp = $this->forum->postGet($this->threadInfo['thread_id'], $start, $num);

        $bach = e107::getScBatch('view', 'forum');
        for($i = count($tmp); $i > 0; $i--)
        {
            $bach->setScVar('postInfo', $tmp[$i-1]);
            $txt .= $tp->parseTemplate($LATESTPOSTS_POST, true);
        }
        $txt .= $tp->parseTemplate($LATESTPOSTS_END, true);
        return $txt;
    }

And v2/e107_plugins/forum/forum_post.php in function getTemplate($type = 'post'), you must add global $LATESTPOSTS_START, $LATESTPOSTS_POST, $LATESTPOSTS_END, $FORUMPOST_REPLY ; at the beginning, and you can find several piece of code related to "REPLY" and "LATESTPOST"

One sure thing is that, inside v2/e107_plugins/forum/templates/forum_post_template.php, the variable $FORUM_POST_TEMPLATE['reply'] is empty and not used, even if you copy some html code inside

ericc-dream commented 3 years ago

Sure Forum_reply

You can also see it there : https://ericc.eu/news.php If you want to test, you will have to create an account and wait until I validate it (to many spammer :-) ) The site is in French ... but well, I'm sure you can navigate into it ;-)

Jimmi08 commented 3 years ago

This should be fixed in the core. I will delete my questions above (they dislike to read too many posts), Be aware, that this is workaround only:

  1. copy actual sc_latestposts under different name f.e. function sc_latestposts_inreply($parm) (because this shortcode is used in latestforum_menu too and I haven't time to test this)

  2. add {LATESTPOSTS_INREPLY} to the end of $FORUM_POST_TEMPLATE['form'] (after {FORUM_POST_FORM_END} shortcode

  3. change the content of that shortcode to:

If this is not planned to be fixed (not supported anymore), they should say this, and then this can be fixed with theme shortcodes.

Thanks again for bringing this, I didn't use V1 so I didn't know this is missing. And this is very good feature.

ericc-dream commented 3 years ago

Nice, it works !! So you have reused the template "newforumpost_menu" .... was the meaning of your previous message. I didn't understood, sorry I will have to tweak the presentation a little bit and it's also appear when I creating a new thread (was expected) but it's way better than nothing

Thanks a lot :+1:

ericc-dream commented 3 years ago

So, in newforumposts_menu_template.php, I created a new "key" to avoid to modify an existing one, and I used it into the "getTemplate" I rebuilt the table taking inspiration on the old one.

In sc_latestposts_inreply, I added

    $num = min($this->threadInfo['thread_total_replies'], $parm);
        if (!isset($num)) {
            return "";
        }

To not print an empty table when creating a new thread/topic so far, so good, I tried to do that since so long ... Thanks again