DLE hacks
Modification of "ShowMore"
26-12-2022, 12:48
Adding a second "Discuss on the Forum" button to BulletEnergy 1.3
Somehow I needed an opportunity on the site for the news to have two "Discuss on the Forum" buttons, one of which would link to one discussion category with its prefix, the other to the informative category with its prefix, but with a different inclination (whether it's a GUIDE, GUIDE or useful tips). That is, I created 1 section with the forum and its subforums and tied one "Discuss" button to it, then created 2 sections with the forum and its subforums, and I already tied the second "Discuss" button to it, thereby getting two different directions for discussing news.
Maybe there are some shortcomings in this hack, since I was looking for a ready-made solution myself, but in the end I decided to do it myself, in principle everything works well, which I achieved, and it turned out. Maybe someone wouldn't like such a thing, too.
So, do not forget to make a backup copy of the edited files and your Database
Download the archive proposed below, drop it into folders and proceed.
In the Database, we make a request
ALTER TABLE dle_post ADD topic_id2 int(11) unsigned DEFAULT '0';
ALTER TABLE dle_be_attachment ADD topic_id2 int(11) unsigned NOT NULL DEFAULT '0';
We go along the way:
engine\bullet_energy\classes\admin.class.php
Looking for:
if($row['action'] == 'discussion') {
$row['param'] = unserialize($row['param']);
}
Insert below:
if($row['action'] == 'discussion2') {
$row['param'] = unserialize($row['param']);
}
We are looking for such lines:
} elseif(in_array(self::$action['get'], array(
'category',
'questions',
'advertising',
'trophies',
'discussion',
Below we insert:
'discussion2',
We are looking for:
$menu .= '<li><a class="template" href="' . self::$path . '?mod=bullet_energy&action=discussion">' . self::$bullet_energy_lang['setting_300'] . '</a></li>';
Below we insert:
$menu .= '<li><a class="template" href="' . self::$path . '?mod=bullet_energy&action=discussion2">' . self::$bullet_energy_lang['setting_300'] . '</a></li>';
We follow the path:
engine\bullet_energy\classes\link.class.php
Looking for:
public function discussion($id = 0)
{
if($this->cpu) {
$result = "{$this->root}{$this->router['main']}/discussion-{$id}{$this->endLinckSymbol}";
} else {
$result = "{$this->root}?do={$this->router['main']}&action=discussion&id={$id}";
}
return $result;
}
Insert below:
public function discussion2($id = 0)
{
if($this->cpu) {
$result = "{$this->root}{$this->router['main']}/discussion2-{$id}{$this->endLinckSymbol}";
} else {
$result = "{$this->root}?do={$this->router['main']}&action=discussion2&id={$id}";
}
return $result;
}
We follow the path:
engine\bullet_energy\action\admin\references.php
Looking for:
$rewRulle[] = 'RewriteRule ^' . parent::$bulletRouter['main'] . '/discussion-([0-9]+)(/?)+$ index.php?do=' . parent::$bulletRouter['main'] . '&action=discussion&id=$1 [L]';
Insert below:
$rewRulle[] = 'RewriteRule ^' . parent::$bulletRouter['main'] . '/discussion2-([0-9]+)(/?)+$ index.php?do=' . parent::$bulletRouter['main'] . '&action=discussion2&id=$1 [L]';
We follow the path:
engine\bullet_energy\api\bullet_api.class.php
Looking for:
if($row['action'] == 'discussion') {
$row['param'] = unserialize($row['param']);
}
Insert below:
if($row['action'] == 'discussion2') {
$row['param'] = unserialize($row['param']);
}
Looking for:
public function setLinckDiscus(array $data = array())
Insert above:
public function setLinckDiscus2(array $data = array())
{
$this->cache['template'] = $this->getCache('template');
if(!is_array($this->cache['template'])) {
$this->_setCache();
return $this->setLinckDiscus2($data);
}
if($this->member_id['user_group'] == 0 OR !isset($this->cache['template']['discussion2']['tree'][$data['tree']])) {
return false;
}
if(empty($data['id'])) {
return '<a href="' . $this->link->discussion2($data['idPost']) . '">' . $this->bullet_energy_lang['topic_148_1'][0] . '</a>';
} else {
$row = $this->db->super_query("SELECT reply_count, title FROM " . PREFIX . "_be_topic WHERE id = {$data['id']}");
if ( !$row ) {
$this->db->query("UPDATE " . PREFIX . "_post SET topic_id2 = 0 WHERE id = {$data['idPost']}");
return '<a href="' . $this->link->discussion2($data['idPost']) . '">' . $this->bullet_energy_lang['topic_148_1'][0] . '</a>';
}
else return '<a href="' . $this->link->topic_linck($data['id'], totranslit($row['title'], true, true)) . '">' . $this->bullet_energy_lang['topic_148_1'][1] . '(' . $this->bullet_energy_lang['topic_148'][2] . $row['reply_count'] . ')' . '</a>';
}
}
There is not a big note in this public, I set the visibility of the "Discuss" button for guests, but there was a problem with the fact that guests could create topics in the forum by simply clicking on the button, now everything is fixed, if a guest clicks on the button, he will go to the forum page with the inscription "You are unauthorized, or not defined publication ID."
Follow the path:
engine\bullet_energy\library\language\utf-8\Russian\site.lng
Looking for:
'topic_148' => array(
Insert above:
'topic_148_1' => array(
'<strong>DISCUSS ON FORUM 2</strong>',
'Go to the discussion on the forum ',
'Answers'),
Well, or its name, as the button should be called
We go along the way:
.htaccess
Looking for:
RewriteRule ^forum/discussion-([0-9]+)(/?)+$ index.php?do=forum&action=discussion&id=$1 [L]
Insert below:
RewriteRule ^forum/discussion2-([0-9]+)(/?)+$ index.php?do=forum&action=discussion2&id=$1 [L]
engine\modules\show.full.php
Looking for:
$tpl->copy_template = preg_replace ( "#\{date=(.+?)\}#ie", "langdate('\\1', '{$row['date']}')", $tpl->copy_template );
Insert below:
if ( $view_template != "print") {$tpl->set('{forumDiscus2}', $apiBullet->setLinckDiscus2(array(
'idPost' => $row['id'],
'id' => $row['topic_id2'],
'tree' => $category_id)));}
In the full news template
templates\Default\fullstory.tpl
The tag will be available
{forumDiscus2}
We insert it in the place where we want to see the [i][b] button"Discuss on Forum 2"
26-12-2022, 12:48
26-12-2022, 13:38
26-12-2022, 14:35
There are no comments
Information
Users of Visitor are not allowed to comment this publication.