Jump to content

Community

The Jimmo

[JIMMO] Top Posters Plus

Recommended Posts

On 10/7/2017 at 8:54 AM, GazzaGarratt said:

Hi @The Jimmo, any news on the update regarding the 'It only shows "1" all the time at the week view' issue? Thanks.

Hi -

This error popped up again @The Jimmo

I took a look at the source code (widgets/jimmoTopPostersPlus.php) and it seemed to resolve the problem. This error seems to occur when you're not in the top 5 and for weekly only. This means its an issue with the default case and as such the widgets rather than the AJAX folder.

This was the code I found inside the if statement that checks to see if the member is logged in.

$you = \IPS\Db::i()->select( 'author_id, COUNT(author_id) as posts', 'forums_posts', array( 'author_id =' . \IPS\Member::loggedIn()->member_id . ' AND post_date>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1W' ) )->getTimestamp() ), '', '', NULL)->join( 'core_members', 'forums_posts.author_id=core_members.member_id' );

I changed the code to the following:

$myPosts = \IPS\Db::i()->select( 'author_id, COUNT(author_id) as posts', 'forums_posts', array( 'author_id =? AND post_date>?', \IPS\Member::loggedIn()->member_id, \IPS\DateTime::create()->sub( new \DateInterval( 'P1W' ) )->getTimestamp()) , '', '', array('author_id'))->join( 'core_members', 'forums_posts.author_id=core_members.member_id' );
if (count($myPosts > 0)) {
	foreach ($myPosts as $col) {
		$y = $col['posts'];
    }
    $you = $y;
} else {
	$you = 0;
}

 

To explain: I've changed it so both parameters in the where clause are parameterized and I've made it group it by author_id. Then I've checked to see if there is a result (a new member with 0 posts wouldn't have any results returned). Then I've just selected it.

A neater way would probably be the try-catch-block using the ->first() method where if it fails you assign $you to 0, but this was just a quick dirty fix for me.

Hope this helps some other people ?

Cheers.

Edited by Devin Powers

Share this post


Link to post
Share on other sites
On 5/17/2018 at 8:32 PM, Devin Powers said:

To explain: I've changed it so both parameters in the where clause are parameterized and I've made it group it by author_id. Then I've checked to see if there is a result (a new member with 0 posts wouldn't have any results returned). Then I've just selected it.

 A neater way would probably be the try-catch-block using the ->first() method where if it fails you assign $you to 0, but this was just a quick dirty fix for me.

Hope this helps some other people ?

Cheers.

For people who may struggle fixing the source code itself, there's a much simpler, but equally effective solution. If the member has not made any posts, then the variable $you gets passed as a SQL query. Hence inside the template you can add this little workaround:

{{if !(is_numeric($you))}}
	<span>0</span>
{{else}}
	<span>{expression="\IPS\Member::loggedIn()->language()->formatNumber( $you )"}</span>
{{endif}}

To edit the template go to: AdminCP -> Customization -> Edit HTML and CSS -> Templates -> jimmotoppostersplus -> jimmoTopPostersPlusRows

EDIT: This only replaces the 1 with a 0 if you have no posts that week.

Edited by Robiss767

Share this post


Link to post
Share on other sites

I am seeing duplicate content error for all of the links in this app. This is caused by the app pulling the index pages meta tags and using them instead of having their own meta tags, or instead of inserting something like "Top Posters - " at the start of the title tag.  I am hoping for a quick fix for this issue. Examples:

https://www.celiac.com/index.php?app=jimmotoppostersplus&module=ajax&controller=ajax&do=topposters&time=all&limit=5&orientation=vertical&groupWhere=

https://www.celiac.com/index.php?app=jimmotoppostersplus&module=ajax&controller=ajax&do=topposters&time=month&limit=5&orientation=vertical&groupWhere=

and compare to the meta tags on my index page:

https://www.celiac.com/

Share this post


Link to post
Share on other sites
15 hours ago, sadams101 said:

I am seeing duplicate content error for all of the links in this app. This is caused by the app pulling the index pages meta tags and using them instead of having their own meta tags, or instead of inserting something like "Top Posters - " at the start of the title tag.  I am hoping for a quick fix for this issue. Examples:

https://www.celiac.com/index.php?app=jimmotoppostersplus&module=ajax&controller=ajax&do=topposters&time=all&limit=5&orientation=vertical&groupWhere=

https://www.celiac.com/index.php?app=jimmotoppostersplus&module=ajax&controller=ajax&do=topposters&time=month&limit=5&orientation=vertical&groupWhere=

and compare to the meta tags on my index page:

https://www.celiac.com/

 

So this is an interesting "quirk." Not necessarily a bug with the top posters plus app as it does not touch meta tags, etc... itself. This "page" is actually not even a real page necessarily. This "quirk" is related to how the IPS core software handles meta tags with the meta tag editor. If you have assigned tags using the meta tag editor to the "/" URL then this will happen as we use query strings in the URL to use this ajax call and not a distinct FURL.

Little technical background, "/" = "/index.php"  therefore the IPS core software is saying "Hey, they want these meta tags here too" and places them on the URLs you listed.

To fix this, you can apply the following furl.json file to /applications/jimmotoppostersplus/data/ . This will assign a custom FURL to this page and you won't see any meta tags you've assigned to "/" on the page anymore. If you have any issues, make sure you clear your cache.

(in the future, we'll see if we can't add a "noindex" tag to this "page" as well as there shouldn't be any worthwhile index-worthy data there.)

 

 

furl.json

Edited by The Jimmo

Share this post


Link to post
Share on other sites

Thank you for this, as your solution did remove the duplicate meta tags. I did try adding to the Meta tags editor various entries try to customize the meta tag but this failed:

top-posters-plus/all/5/vertical/*

It would be nice to make it work in the meta tags editor at some point.

Share this post


Link to post
Share on other sites

To use this in the meta tag editor, you would want to do the below as there are some variables in that URL which may be impacting you:

top-posters-plus/*

 

image.thumb.png.e08eca6538c2bf12cb4b73bbe4aabe87.png

image.png.7a6df3c655ee4eb7ed39f82aab2eae31.png

Share this post


Link to post
Share on other sites

Yeah, that's from the core. Essentially, you could create an FURL for it via the ACP or bring this up to IPS but I'm not sure if they would say that is working as intended or not.

Share this post


Link to post
Share on other sites
On 9/14/2019 at 11:52 AM, DarkClaWz said:

Hey,

was willing to know if you can add an option to manually set the weekly posters to zero?
thanks.

Not sure I understand. Are you wanting to set the numbers of authors to none or the post count of the authors to zero? If either of those are wanted here, that really contradicts the purpose and usefulness of the block. 

Share this post


Link to post
Share on other sites

 

2 hours ago, The Jimmo said:

Not sure I understand. Are you wanting to set the numbers of authors to none or the post count of the authors to zero? If either of those are wanted here, that really contradicts the purpose and usefulness of the block. 

I want to set to zero the post count of only the weekly posters when I want. The reason is we want to make a competition of daily posts - user posts the most posts wins.
but now that I think about it it`s a bad idea. thanks anyway, sorry if I bothered you 👍
Thanks for fast response!

Share this post


Link to post
Share on other sites
7 hours ago, DarkClaWz said:

 

I want to set to zero the post count of only the weekly posters when I want. The reason is we want to make a competition of daily posts - user posts the most posts wins.
but now that I think about it it`s a bad idea. thanks anyway, sorry if I bothered you 👍
Thanks for fast response!

Not a bother. Always welcome to submit ideas/suggestions!

Share this post


Link to post
Share on other sites

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...