Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

hashtags Plugin v1

 
Post new topic   Reply to topic    Smarty Forum Index -> Plugins
View previous topic :: View next topic  
Author Message
Aliresalat
Smarty Rookie


Joined: 09 Feb 2014
Posts: 23
Location: Iran

PostPosted: Wed Aug 13, 2014 5:23 pm    Post subject: hashtags Plugin v1 Reply with quote

Hello again

A plugin for creating a hash tag in the comments section or any part that you think should have the capability
Version 1 of the system is very simple
In the next major version of the system will

File Name: modifier.hashtags.php
Code :

Code:


<?php

/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * hashtags v1
 * File name: modifier.hashtags.php
 * Name:     hashtags
 * Date:     2014.08.13
 *
 * Examples1: {$comments[comment].content|hashtags}
 * Examples2: {$comments[comment].content|badWordsFilter|hashtags}
 *
 * @author : Ali Resalat (300)
 * @E-mail : info.Aliresalat@Gmail.com
 * @Yahoo ID : Mitooo.Mitooo
 * @Web site : www.Amtis.ir
 * @Mobile : 09359743850/09149466063
 */

function smarty_modifier_hashtags($str, &$content='')
{

   $regex = "/#+([a-zA-Z0-9_]+)/";
   $str = preg_replace($regex, '<a href="hashtag.php?tag=$1">$0</a>', $str);
      return($str);


$string = convertHashtags($string);
echo $string;

}

/* vim: set expandtab: */

?>



File Name: hashtag.php

Code:


<html lang="fa" dir="rtl">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php

if(isset($_GET["tag"])){
$tag = preg_replace('#[^a-z0-9_]#i', '', $_GET["tag"]);
// $tag is now sanitized and ready for database queries here
$fulltag = "#".$tag;
   echo $fulltag;

mysql_connect("localhost", "root", "300300300")
or die(mysql_error());

mysql_select_db("photo")
or die(mysql_error());

$result = mysql_query("SELECT * FROM images WHERE username='$tag'")

or die(mysql_error());

while ($row = mysql_fetch_array($result)){
    $username = $row['username'];
   // $email = $row['email'];
    echo "<br> Name : $username<br />";   
  //  echo "email  : $email";                   
}


   }
      
?>



Examples1: {$comments[comment].content|hashtags}
Examples2: {$comments[comment].content|badWordsFilter|hashtags}

Output:

#AliResalat <---- link

---------------------------------------------------------
your welcome Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Plugins All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP