#hashtag

1.31K
.
# Koenig (26.06.2017 / 10:22)
Eternal, можно и так, тогда функция попадает в $tools и придётся $tools->checkout() изменять, или добавить ББ, оно уже прописано в чекаут
johncms.com/forum/index.php?act=post&id=1021803
первое слов
Короче это и не модуль толком. Так как автор просил помощи. Страницы нет с результатами
.
kantry
Hey guys! Finally I'm gonna change status!?
Eternal, Ты чего пристал? Этого модуля нет в стандартном движке, автор придет и спросишь у него.
.
jimy
sorry long time not on.

i'll share mine
open bbcode.php

find
public function __invoke(ContainerInterface $container)

add
$this->db = $container->get(\PDO::class);


find
public function tags($var)

add
$var = $this->hashTag($var);


last add protected function
/* mod HashTag system by jimy ironyzm */
	/* author: jimy */
	protected function hashTag($var) {
		$HashTag = '/(?<!:|\s|&|"|\')(^|\s)#([-a-z0-9_-]{3,20})/si';
		$var = str_replace('>#','> #',$var);
		$var = preg_replace_callback($HashTag, function($tags) {
			$tg = htmlspecialchars(trim($tags[2]));
			return $tags[1].'<a href="'.$homeurl.'/page/?act=tags&amp;src='.$tg.'" title="'._t('In-Tags: '.$tags[0].'','system').'"><span class="tagcon">'.$tags[2].'</span></a>';
		},$var);
		
		$UserTag = '#(^|[\n\s])@([-a-z0-9_-]{3,20})#si';
		$var = preg_replace_callback($UserTag, function($name) {
			$tg = htmlspecialchars(trim($name[2]));
			$user = $this->db->prepare('SELECT * FROM `users` WHERE `name` = ? LIMIT 1');
			$user->execute([$tg]);
			if ($user->rowCount() > 0 && $this->user->isValid()) {
				$users = $user->fetchColumn();
				return $name[1].'<a href="'.$homeurl.'/profile/?user='.$users['id'].'" title="'.$name[0].'">'.$name[0].'</a>';
			} else {
				return $name[1] . '@' . $name[2];
			}
		},$var);
		return $var;
	}


then open your style.css
add
.tagcon {
	display: inline-block;
}
.tagcon:before {
	content: "#";
	font-size: 15px;
	margin-right:2px;
	font-style:italic;
}



note :
1. pls make new $act in root/page/index.php for getting tags list
2. usage = @jimy #handsome / both @jimy and #handsome will be link into user profile and page/?act=tags
.
jimy
Добавлено: 01.07.2017 / 08:05
# EMINEM (23.06.2017 / 21:15)
jimy, An excellent function, is there a script that will make this function work?
Why is there no archive /page/?
for page/?act=tag I made I myself u can make new directory / just use existing directory and change the link as you want, mine is for example.
to get the hashtag
<a href="'.$homeurl.'/page/?act=tags&amp;src='.$tg.'" title="'._t('In-Tags: '.$tags[0].'','system').'">

Добавлено: 01.07.2017 / 08:13
for example #hastag I request its from table discus (nb: u can use forum/news/guestbook/etc.)

table
DROP TABLE IF EXISTS `discus`;
CREATE TABLE `discus` (
  `id`	INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `time`	INT(10) UNSIGNED NOT NULL DEFAULT '0',
  `user_id`	int(10) unsigned NOT NULL DEFAULT '0',
  `name` TEXT	NOT NULL,
  `text` TEXT	NOT NULL,
  `close` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
  `tag_name`    VARCHAR(250)     NOT NULL DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `tag_name` (`tag_name`)
)
  ENGINE = MyISAM
  DEFAULT CHARSET = utf8mb4;


code in /page/?act=tags
/* mod HashTag system by jimy ironyzm */
	/* author: jimy */
$rev = $db->query("SELECT * FROM `discus` WHERE `tag_name` = '".$src."'")->fetch();
if($src != $rev['tag_name']){
	$url = '?act=tags';
	header('refresh:5;url='.$url.'');
	echo '<div class="menu">Sorry Tags Not-Found or Maybe Deleted! <hr/> u\'ll redirect in 5 sec.</div>';
	require('../system/end.php');
	exit;
}
	/* mod HashTag system by jimy ironyzm */
	/* author: jimy */
if(empty($src) || $src != $rev['tag_name']){
	$reg = $db->query("SELECT * FROM `discus` GROUP BY `tag_name` ORDER BY `id`");
	if ($reg->rowCount()) {
		echo '<div class="menu">';
		while ($rez = $reg->fetch()) {
			$usage = $db->query("SELECT COUNT(*) FROM `discus` WHERE `tag_name` = '".$rez['tag_name']."'")->fetchColumn();
			echo '<a href="../page/?act=tags&amp;src='.$rez['tag_name'].'" title="'._t('In-Tags: #'.$rez['tag_name'].'','system').'"><span class="tagcon">'.$rez['tag_name'].' = '.
				 $usage.'</span></a>';
				++$i;
		}
		echo '</div>';
	} else {
		echo '<div class="menu center"><b>'._t('No Tags!','system').'</b></div>';
	}
}

_______________________

Только русский и английский!
.
jimy, Can you give me a example of writing in mysql base tags (form and query)
Всего: 25