Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Guys!
- I'm asking any interesting people who may help to integrate the latest comments natively to udjacomments,
- but for now i want to bring you a straight solution which just works. Whole part of this code belongs to MrWheeli, ukrainian blogger and web-developer.
- Source article here: http://www.mrweevil.com/index.php/phpmysql/21-vyvodymo-ostanni-komentari-na-udja-comments
- So, as udja stores its comments in database, we can write php code to extract them and display somewhere on the site. This code you need to insert in Custom html module page and choose where to display it, and you got it!
- [code]
- <?
- $db = mysql_connect ("server address",bd_username","bd_userpassword");
- mysql_select_db ("bd_name");
- mysql_query("SET NAMES utf8");
- $result_udja
- = mysql_query ("SELECT id,full_name,content,comment_url FROM
- i8ntl_udjacomments WHERE is_published='1' ORDER BY time_added DESC, id
- DESC LIMIT 5");
- if (!$result_udja)
- {
- echo "<p>Opps, error!<br>Report to administrator e-mail<br>Error:</p>";
- exit (mysql_error());
- }
- if (mysql_num_rows($result_udja) > 0)
- {
- $myrow_udja = mysql_fetch_array ($result_udja);
- echo "<br><p class='last_title'>Last comments: </p>";
- do
- {
- $text = $myrow_udja ['content'];
- $text = substr ($text,0,200);
- $url_link = $myrow_udja ['comment_url'];
- $url_link = substr ($url_link,12,3);
- $result_udja1 = mysql_query ("SELECT id,alias,catid FROM i8ntl_content WHERE id='$url_link'");
- $myrow_udja1 = mysql_fetch_array ($result_udja1);
- $id = $myrow_udja1 ['id'];
- $catid = $myrow_udja1 ['catid'];
- $alias = $myrow_udja1 ['alias'];
- $result_udja2 = mysql_query ("SELECT alias FROM i8ntl_categories WHERE id='$catid'");
- $myrow_udja2 = mysql_fetch_array ($result_udja2);
- $catalias = $myrow_udja2 ['alias'];
- printf ("<p class='last_auth'><a
- href='http://yoursite.com/index.php/%s/%s-%s'>%s</a></p><p
- class='last_comment'>%s</p>", $catalias, $id, $alias,
- $myrow_udja["full_name"], $text);
- }
- while ($myrow_udja = mysql_fetch_array($result_udja));
- }
- else
- {
- echo "<p>No data to fulfill your request!</p>";
- exit();
- }
- ?>
- [/code]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement