Latest commented on

Discuss PivotX 2.0.x here. Non-PivotX related discussions go in The Drain.

Latest commented on

Postby Marza » Thu Jan 21, 2010 3:54 am

Instead of latest comments, I would prefer to display a list of x entries that have been commented on recently. A list of active discussions, so to say.

Code: Select all
[[ recently_commented_on
 format="<a href='%url%#comm' title='%date%'>%title%</a> (%commcount%)<br />"
 count=6
]]


Is this something that can be achieved already in some way I haven't figured out, something for the wishlist or more likely to be added with an extension?
Marza
 
Posts: 85
Joined: Sat Dec 12, 2009 8:49 pm

Re: Latest commented on

Postby Bob » Sun Jan 24, 2010 5:13 pm

This is not possible, currently..

However, if you're using MySQL, it shouldn't be too hard, to do something like this:

Code: Select all
        [[php]]

global $PIVOTX;

$sql = new sql('mysql',
            $PIVOTX['config']->get('db_databasename'),
            $PIVOTX['config']->get('db_hostname'),
            $PIVOTX['config']->get('db_username'),
            $PIVOTX['config']->get('db_password')
        );

$sql->query("SELECT `entry_uid` FROM pivot_comments GROUP BY `entry_uid` ORDER BY `date` DESC LIMIT 20;");

// Get the results.
$rows = $sql->fetch_all_rows();

// make them manageable..
$rows = implode(', ', make_valuepairs($rows, '', 'entry_uid'));

// Assign them in smarty
$this->assign('latest_uids', $rows);


[[/php]]
[[ subweblog .. uid="$latest_uids" ]] ... [[/subweblog ]]



In the subweblog as mentioned here, you get the entries that were last commented on, in the right order.
Bob
Lead Developer
 
Posts: 1374
Joined: Tue Nov 20, 2007 11:16 pm

Re: Latest commented on

Postby Marza » Mon Jan 25, 2010 4:34 am

Bob, I tried your code, but get an error in the log files:
Code: Select all
error_no: 1146
2010-01-25 05:29:25 - 0.195 -- modules/module_debug.php:310 / debug_printbacktrace() --  ( 11445484 )
» HTML/index.php:24              - require_once( '/var/www/g27059/mydomain.nl/HTML/pivotx/render.php' )
» pivotx/render.php:236          - Parser->render()
» modules/module_parser.php:101  - Parser->renderPage()
» modules/module_parser.php:161  - Parser->renderWeblog()
» modules/module_parser.php:352  - Parser->parseTemplate( 'mydomain/test_template.html' )
» modules/module_parser.php:1176 - Smarty->fetch( 'mydomain/test_template.html' , '' )
» smarty/Smarty.class.php:1271  - include( '/var/www/g27059/mydomain.nl/HTML/pivotx/db/cache/%%85~' )
» cache/%%85^857^857CA3BD%%test_template.html.php:47 - sql->query( 'SELECT 'entry_uid' FROM pivot_comments GROUP BY 'e~' )
» modules/module_sql.php:320    - sql->error( '' , 'SELECT 'entry_uid' FROM pivot_comments GROUP BY 'e~' , 1146 )
» modules/module_sql.php:248    - debug_printbacktrace()


I know near to nothing about mysql queries, but the GROUP BY 'e~' strikes me as odd.

I'm using PivotX - 2.1.0: beta 3 , php 5.2.4-2ubuntu5.10, mysql 5.0.32
Marza
 
Posts: 85
Joined: Sat Dec 12, 2009 8:49 pm

Re: Latest commented on

Postby Harm10 » Mon Jan 25, 2010 3:54 pm

Looking at the sample code and your error log it looks like you used the quotes in the wrong way.
The sample is: "SELECT `entry_uid` FROM pivot_comments GROUP BY `entry_uid` ORDER BY `date` DESC LIMIT 20;"
And part still in the cache is: 'SELECT 'entry_uid' FROM pivot_comments GROUP BY 'e~'
As you can see Bob's sample starts and ends with a double-quote as yours seems to start with a single quote.
As far as my knowledge goes in this the quoting within the select should be different compared to the delimiting quoting (i.e. begin and end of the statement).
Maybe you should check your implementation of the sample coding?
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Latest commented on

Postby Marza » Mon Jan 25, 2010 4:48 pm

Nope, just checked, this is the line in my code:
Code: Select all
$sql->query("SELECT 'entry_uid' FROM pivot_comments GROUP BY 'entry_uid' ORDER BY 'date' DESC LIMIT 20;");
Marza
 
Posts: 85
Joined: Sat Dec 12, 2009 8:49 pm

Re: Latest commented on

Postby Harm10 » Mon Jan 25, 2010 5:25 pm

Short search on Google shows that error 1146 means that the table is not found.
As I don't have a sql PivotX install I can't check the table name pivot_comments for existance.
Probably you can in your administration panel. Maybe it should be pivotx_comments?
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Latest commented on

Postby Marza » Mon Jan 25, 2010 5:49 pm

Yes, Harm, should have seen that myself. After chancing that, I get a new error:
Code: Select all
-- modules/module_smarty.php:2245 / _smarty_link_entry() --  ( 10630112 )
Can't create entry link since uid isn't set.


Is that because 'uid' is not part of the arguments that can be used for subweblog?
Marza
 
Posts: 85
Joined: Sat Dec 12, 2009 8:49 pm

Re: Latest commented on

Postby Harm10 » Mon Jan 25, 2010 7:43 pm

Marza wrote:Is that because 'uid' is not part of the arguments that can be used for subweblog?

As I said I'm not familiar with this but logically thinking it looks like there is no userid set, so no logging in has been done?
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Re: Latest commented on

Postby Marza » Mon Jan 25, 2010 8:26 pm

No, I think it is about the 'uid' in the last part of the code:
Code: Select all
[[ subweblog .. uid="$latest_uids" ]] ... [[/subweblog ]]
Marza
 
Posts: 85
Joined: Sat Dec 12, 2009 8:49 pm

Re: Latest commented on

Postby Harm10 » Tue Jan 26, 2010 11:22 am

Does the variable $latest_uids contain something? You can test this by using "echo $latest_uids;"
Quality is in the detail of things............

Want to change or update your PivotX site? Mail or PM me!
I can also convert your site to a Wordpress site!
Harm10
Developer
 
Posts: 2011
Joined: Wed Jun 17, 2009 9:37 am
Location: Somewhere in The Netherlands (aka Holland)

Next

Return to 2.x Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron