Open ericc-dream opened 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
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
Sure
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 ;-)
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:
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)
add {LATESTPOSTS_INREPLY} to the end of $FORUM_POST_TEMPLATE['form'] (after {FORUM_POST_FORM_END} shortcode
change the content of that shortcode to:
there is a change of way how templates are used and fixed shortcode issue I would prefer separate key for forum, but then you will need to add it to newsforum_menu template.
function sc_latestposts_inreply($parm) //TODO move elsewhere?
{
$parm = ($parm ? $parm : 10);
$tp = e107::getParser();
$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);
$template = e107::getTemplate('forum','newforumposts_menu', 'default'); //add your key f.e forum
$LATESTPOSTS_START = $template['start'];
$LATESTPOSTS_POST = $template['item'];
$LATESTPOSTS_END = $template['end'];
$bach = e107::getScBatch('view', 'forum');
$txt = $tp->parseTemplate($LATESTPOSTS_START, true);
for($i = count($tmp); $i > 0; $i--)
{
//$bach->setScVar('postInfo', $tmp[$i-1]);
$bach->setScVar('postInfo', $tmp[$i-1]);
$bach->setVars($tmp[$i-1]);
$txt .= $tp->parseTemplate($LATESTPOSTS_POST, true, $bach);
}
$txt .= $tp->parseTemplate($LATESTPOSTS_END, true);
return $txt;
}
Again, my time is limited, otherwise I would answer you on my site with more explanation. But for sure, this should be fixed in core.
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.
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:
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
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