News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Ajax Profile Comments

Started by The Craw, March 06, 2012, 02:22:44 PM

Previous topic - Next topic

Ashelia

I'll report back here once that has been taken care of, thanks!

The Craw

No problem. Without actually checking, I suspect what's happening here is that $smcFunc is adding an IF NOT EXISTS to my install query, so the old profile_comments table is being preserved.

live627

Good guess! But nope.

What it does is does a SHOW TABLES, looks for the table in question, and if found, do nothing. If it's sett to overwrite, drop and then create. Default is ignore.

The Craw

Thanks for the info, that will come in handy. :)

gasyoun

Quote from: The Craw on March 06, 2012, 02:22:44 PM
This mod uses a few icons from the hxxp:led24.de/iconset/ [nonactive] set.

I see you still use my LED icons. Would you consider FatCow's? Other set, if something is missing, I'm ready to draw it personally for you @ hxxp:webhostingw.com/icon-window/ [nonactive].

The Craw

Those do look nice, however I think if I do change the icons I will draw them myself to avoid outsourcing. At the moment, the mod uses a mixture of icons, some I did myself, and some LED icons.

If you're looking to change your personal mod install to use that set, I'd be willing to help you out there.  :)

FrizzleFried

I install with no errors but I get this error when I attempt to visit my profile:

QuoteUnknown column 'comment_id' in 'field list'
File: /home/ahaforum/public_html/Sources/Profile-View.php
Line: 256

FrizzleFried

I read the solution is to uninstall and re-install.  This did not work for me until I uninstalled FULLY (including the database info) then re-installed... now it's working.

The Craw

Was there another profile comments mod installed before this one? That seems to have been the problem for a lot of people, as the database tables don't play nice with each other.

Diego Andrés

Quote from: The Craw on July 21, 2012, 11:41:02 AM
Was there another profile comments mod installed before this one? That seems to have been the problem for a lot of people, as the database tables don't play nice with each other.

Maybe you can try to use another name, like profile_ajax_comments

SMF Tricks - Free & Premium Responsive Themes for SMF.

The Craw

Quote from: Diego Andrés on July 21, 2012, 11:50:44 AM
Quote from: The Craw on July 21, 2012, 11:41:02 AM
Was there another profile comments mod installed before this one? That seems to have been the problem for a lot of people, as the database tables don't play nice with each other.

Maybe you can try to use another name, like profile_ajax_comments

I could, but then my support thread would be empty, wouldn't it? Strategy, man. ;)

FrizzleFried

I would guess that I did try out the Ultimate Profile mod.  I am guessing that is where the issue would be...

The Craw

That is most likely the problem. I'll have to put warnings about that in the next version. Either that, or pick a unique table name as Diego Andrés suggested.

mahmoudgamal

I Got Error Unknown column 'comment_id' in 'field list'
File: /home/a6497166/public_html/Sources/Profile-View.php
Line: 256

i triad to reinstall it 2 times

The Craw

Quote from: mahmoudgamal on August 05, 2012, 09:19:24 PM
I Got Error Unknown column 'comment_id' in 'field list'
File: /home/a6497166/public_html/Sources/Profile-View.php
Line: 256

i triad to reinstall it 2 times

Most likely you had/have another profile comments mod installed. If it is still installed, try uninstalling that one making sure to also remove its database table by checking "Remove all data associated with this modification." If you've already uninstalled that mod and forgot to remove its database table, open phpmyadmin and run the following query in your SMF database.


DROP TABLE `smf_profile_comments`;


That is of course assuming that your db_prefix is set to "smf_"

Also, you could have saved yourself a heap of time by reading the previous pages of this topic, as this problem has come for a number of people.  ::)

Jessica.

Quote from: trabacho on June 12, 2012, 11:57:03 AM
I've made an addon for this to notificate my users.

So I share it with you, to the Mod Creater I would be happy if you take it in.

Here the changes:

SQL:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;



CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Edits:

Profile-View.php:

INSERT BEFORE:


$q =$smcFunc['db_query']('', '
SELECT comment_id, comment_poster_id, comment_poster, comment_title, comment_body
FROM {db_prefix}profile_comments
WHERE comment_profile= {int:profile_id}
ORDER BY comment_id DESC
LIMIT 20',
array ('profile_id' => $memID)
);


-------------------


$q =$smcFunc['db_query']('', '
SELECT p_id
FROM {db_prefix}profile_visits
WHERE v_id= {int:visitor_id} AND p_id={int:profile_id}',
array ('visitor_id' => $user_info['id'], 'profile_id' => $memID)
);

if( $smcFunc['db_num_rows']($q) != 0 )
$smcFunc['db_query']('', '
UPDATE {db_prefix}profile_visits
SET lastvisit = CURRENT_TIMESTAMP
WHERE p_id= {int:profile_id} AND v_id= {int:visitor_id}',
array ('profile_id' => $memID, 'visitor_id' => $user_info['id'])
);
else
$smcFunc['db_insert']('insert',
            '{db_prefix}profile_visits',
            array(
                'v_id' => 'int', 'p_id' => 'int',
            ),
            array(
                $user_info['id'], $memID,
            ),
            array()
        );


Subs.php:

Replace:


function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;


---------------------


function setupMenuContext()
{
global $smcFunc, $context, $modSettings, $user_info, $txt, $scripturl;


:::::::::::::::::::::::::::::::

Replace:


if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}


--------------------


$query =$smcFunc['db_query']('', '
SELECT lastvisit
FROM {db_prefix}profile_visits WHERE
p_id={int:visitor_id} AND v_id={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$lastvisited = $smcFunc['db_fetch_assoc']($query);

if($lastvisited != NULL)
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id} AND date > "'.$lastvisited['lastvisit'].'"',
array ('visitor_id' => $user_info['id'])
);
else
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$commentscount = $smcFunc['db_num_rows']($query);

if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0 || $commentscount > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . ($context['user']['unread_messages']+$commentscount) . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . ($context['user']['unread_messages']+$commentscount) . '</strong>]';
if($context['user']['unread_messages'] != 0)
$context['menu_buttons']['pm']['sub_buttons']['pm_read']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
$context['menu_buttons']['pm']['sub_buttons']['profile_read']['title'] .= ' [<strong>' . $commentscount . '</strong>]';
}


:::::::::::::::::::::::::::::::

Replace:

'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
'is_last' => true,
),
),
),


---------------------------


'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
),
'profile_read' => array(
'title' => $txt['profile_read'],
'href' => $scripturl . '?action=profile',
'show' => true,
'is_last' => true,
),
),
),


index.german.php:

Add:


$txt['profile_read'] = 'Profilkommentare';


index.english.php:

Add:


$txt['profile_read'] = 'Read your Comments';


The positive of the new profile_visits is, you can use it for a box on the Profile which is like the Who visited my Profile in vBulletin!

for some reason I don't understand your edits. for the first step, which one is the one I have to insert?
Testing Zone - SMF 2.0.7, default Curve
School & Chat - phpBB3, over 170 mods installed, official live forum

I use the latest version of Chrome

phpBB: Forum = a section; Board = whole site
SMF: Forum = whole site; Board = a section

The Craw

This part:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;


And this part:


CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Are both applied to your SMF database in PHPMyAdmin. You can run those in a query window.

The rest of the edits are done in SMF files and should be somewhat easy to follow.

ocmdiaz714

Quote from: The Craw on August 20, 2012, 01:34:20 PM
This part:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;


And this part:


CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Are both applied to your SMF database in PHPMyAdmin. You can run those in a query window.

The rest of the edits are done in SMF files and should be somewhat easy to follow.

How does it modify users they have new comments? Also can somebody tell me how to make the avatars bigger without ruining the template? I tried doing so manually, and messed up. If not possible to fetch the default max. avatar size I would like to have a max display of 160x160. Also can somebody tell me how to wrap the table around a border so it can look like the table above? Ex:



Thanks.

ocmdiaz714

Quote from: trabacho on June 12, 2012, 11:57:03 AM
I've made an addon for this to notificate my users.

So I share it with you, to the Mod Creater I would be happy if you take it in.

Here the changes:

SQL:


ALTER TABLE `prefix_profile_comments` ADD `date` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ;



CREATE TABLE prefix_profile_visits (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`v_id` INT( 11 ) NOT NULL ,
`p_id` INT( 11 ) NOT NULL ,
`lastvisit` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE = InnoDB


Edits:

Profile-View.php:

INSERT BEFORE:


$q =$smcFunc['db_query']('', '
SELECT comment_id, comment_poster_id, comment_poster, comment_title, comment_body
FROM {db_prefix}profile_comments
WHERE comment_profile= {int:profile_id}
ORDER BY comment_id DESC
LIMIT 20',
array ('profile_id' => $memID)
);


-------------------


$q =$smcFunc['db_query']('', '
SELECT p_id
FROM {db_prefix}profile_visits
WHERE v_id= {int:visitor_id} AND p_id={int:profile_id}',
array ('visitor_id' => $user_info['id'], 'profile_id' => $memID)
);

if( $smcFunc['db_num_rows']($q) != 0 )
$smcFunc['db_query']('', '
UPDATE {db_prefix}profile_visits
SET lastvisit = CURRENT_TIMESTAMP
WHERE p_id= {int:profile_id} AND v_id= {int:visitor_id}',
array ('profile_id' => $memID, 'visitor_id' => $user_info['id'])
);
else
$smcFunc['db_insert']('insert',
            '{db_prefix}profile_visits',
            array(
                'v_id' => 'int', 'p_id' => 'int',
            ),
            array(
                $user_info['id'], $memID,
            ),
            array()
        );


Subs.php:

Replace:


function setupMenuContext()
{
global $context, $modSettings, $user_info, $txt, $scripturl;


---------------------


function setupMenuContext()
{
global $smcFunc, $context, $modSettings, $user_info, $txt, $scripturl;


:::::::::::::::::::::::::::::::

Replace:


if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
}


--------------------


$query =$smcFunc['db_query']('', '
SELECT lastvisit
FROM {db_prefix}profile_visits WHERE
p_id={int:visitor_id} AND v_id={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$lastvisited = $smcFunc['db_fetch_assoc']($query);

if($lastvisited != NULL)
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id} AND date > "'.$lastvisited['lastvisit'].'"',
array ('visitor_id' => $user_info['id'])
);
else
$query =$smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}profile_comments WHERE
comment_poster_id!={int:visitor_id} AND comment_profile={int:visitor_id}',
array ('visitor_id' => $user_info['id'])
);

$commentscount = $smcFunc['db_num_rows']($query);

if (!$user_info['is_guest'] && ($context['user']['unread_messages'] > 0 || $commentscount > 0) && isset($context['menu_buttons']['pm']))
{
$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . ($context['user']['unread_messages']+$commentscount) . ']';
$context['menu_buttons']['pm']['title'] .= ' [<strong>' . ($context['user']['unread_messages']+$commentscount) . '</strong>]';
if($context['user']['unread_messages'] != 0)
$context['menu_buttons']['pm']['sub_buttons']['pm_read']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
$context['menu_buttons']['pm']['sub_buttons']['profile_read']['title'] .= ' [<strong>' . $commentscount . '</strong>]';
}


:::::::::::::::::::::::::::::::

Replace:

'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
'is_last' => true,
),
),
),


---------------------------


'pm' => array(
'title' => $txt['pm_short'],
'href' => $scripturl . '?action=pm',
'show' => $context['allow_pm'],
'sub_buttons' => array(
'pm_read' => array(
'title' => $txt['pm_menu_read'],
'href' => $scripturl . '?action=pm',
'show' => allowedTo('pm_read'),
),
'pm_send' => array(
'title' => $txt['pm_menu_send'],
'href' => $scripturl . '?action=pm;sa=send',
'show' => allowedTo('pm_send'),
),
'profile_read' => array(
'title' => $txt['profile_read'],
'href' => $scripturl . '?action=profile',
'show' => true,
'is_last' => true,
),
),
),


index.german.php:

Add:


$txt['profile_read'] = 'Profilkommentare';


index.english.php:

Add:


$txt['profile_read'] = 'Read your Comments';


The positive of the new profile_visits is, you can use it for a box on the Profile which is like the Who visited my Profile in vBulletin!

Could you tell me what I'm doing wrong? I get this error when I try to run the first query.

Quote#1146 - Table 'mytable.prefix_profile_comments' doesn't exist

Rain Forest

Quote from: Jessica. on March 16, 2012, 04:16:50 PM
when you get a comment, is there a notification? if not, there should be one...though I would like it if it's not by PM or email but instead there's a message in the top of the forum like

1 New Comments

I agree! #2

Advertisement: