Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2008-08-08 23:25:35

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

Re: wlk_helpful, a rating plugin

Do you only have 5 articles on the site?

….ermm…..that’s the only reason I could see that happening.

Offline

#50 2008-08-09 07:54:42

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: wlk_helpful, a rating plugin

Walker wrote:

Do you only have 5 articles on the site?

….ermm…..that’s the only reason I could see that happening.

—————————-
No, there are more than 500 articles …

The database has also enough negative counts/entries.
txp_wlk_helpful 140
txp_wlk_helpful_counts 588

If I change the code for the wlk_helpful_list function in this line

'order'=> (isset($prefs['wlk_helpful_list_which']) && $prefs['wlk_helpful_list_which']=='bottom')?'ASC':'DESC',

to ‘DESC’:‘ASC

I get the opposite result – the “bottom” or “negative” – for both parameters “which=‘top’” and “which=‘bottom’”. That show’s me, that the script can calculate a negative list.
Any hints?

Offline

#51 2008-08-10 22:50:32

whocarez
Plugin Author
From: Germany/Ukraine
Registered: 2007-10-08
Posts: 305
Website GitHub Twitter

Re: wlk_helpful, a rating plugin

Problem solved, not in a clever way, but solved.
Maybe I expressed the problem not clearly.
I wanted to show at the same time two lists: the top and the bottom. But all the time there were the same lists in “txp:wlk_helpful_list which=‘top’” and “txp:wlk_helpful_list which=‘bottom’”. So the solution was to create a second function wlk_helpful_list because: you can’t use a variable two times. For all the plugin programmers the problem is clear, but it was it not for me.
So I solved the problem in creating a second wlk_helpful_list2 and now I got two lists on my site.

Ok, maybe a little bit stupid but it works …

Offline

#52 2008-11-20 11:32:23

paxrex33
Member
Registered: 2007-10-25
Posts: 15

Re: wlk_helpful, a rating plugin

Is it possible to stop the same person (cookie, IP check) to rate the article more times?

Offline

#53 2008-11-20 14:45:41

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

Re: wlk_helpful, a rating plugin

erm. it already does the IP check.

Offline

#54 2009-02-18 19:40:53

vaughn-taylor
Member
From: New Orleans
Registered: 2004-08-06
Posts: 17
Website

Re: wlk_helpful, a rating plugin

I’m not sure if this problem was resolved by anybody yet, but if you want the Yes/No links to stop popping you to the top of the page, just make a simple modification to the wlk_helpful.js — adding return false; in two places as shown below:

$(document).ready(function(){

$(".wlk_helpfulplus").bind("click", function(e){

page_var = $(this);

thecount = page_var.parents('.plus').children('.thecount').html();

article_id = page_var.parents('.plus').children('.thisid').html();

jQuery.post('/wlk_helpful_ajax', {"article_id":article_id,"up_down":'up'}, function(data){

if(data.length > 0) {

page_var.parents('.plus').children('.thecount').html(parseInt(thecount)+1);

}

});

return false;

});

});

//Rate it down 1

$(document).ready(function(){

$(".wlk_helpfulminus").bind("click", function(e){

page_var = $(this);

thecount = page_var.parents('.minus').children('.thecount').html();

article_id = page_var.parents('.minus').children('.thisid').html();

jQuery.post('/wlk_helpful_ajax', {"article_id":article_id,"up_down":'down'}, function(data){

if(data.length > 0) {

page_var.parents('.minus').children('.thecount').html(parseInt(thecount)+1);

}

});

return false;

});

});


Work until your carpal tunnel makes you cry.
—————————-
My “bloggy” TP site >> liberalrevolt.com

Offline

#55 2010-10-26 13:43:40

wornout
Member
From: Italy
Registered: 2009-01-20
Posts: 256
Website

Re: wlk_helpful, a rating plugin

I don’t know why but ajax can’t found the section wlk_helpful_ajax

Offline

#56 2011-08-20 17:12:09

Jaro
Member
From: S/F
Registered: 2004-11-18
Posts: 89

Re: wlk_helpful, a rating plugin

I was wondering if it’s difficult to modify the plugin so that it could output a list of most popular articles (based on votes) in other than predefined format. Current format is:

<ol id=“wlkhlpflbottom”>
<li><a href=“permalink”>Article Title 1</a></li>
<li><a href=“permalink”>Article Title 2</a></li>
etc.
</ol>

I would something like this:

<ol id=“wlkhlpflbottom”>
<li><a href=“permalink”>*Article 1 Thumbnail*</a></li>
<li><a href=“permalink”>*Article 2 Thumbnail*</a></li>
etc.
</ol>

I’ve been playing around with the plugin but couldn’t figure it out with my limited PHP knowledge.

Last edited by Jaro (2011-08-20 17:13:01)

Offline

#57 2011-08-20 20:56:21

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,303

Re: wlk_helpful, a rating plugin

Jaro, you could try the following. It’s untested, I’ve only looked at the (not completely installed) code of the plugin and copied over from my mod of stm_article_order:

Search for

    function wlk_helpful_list($atts)
    {

Replace by

    function wlk_helpful_list($atts)
    {
		global $img_dir;

Search for

    '.$article['Title'].'

Replace by

    <img class="article-img" src="'.hu.$img_dir.'/'.$article['Image'].'t.jpg" />

The latter as you’ll see easily will output only JPGs, it’s the only output I could get working in my copy of stm_article_order (limited PHP knowledge, likewise)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#58 2011-08-21 08:57:28

Jaro
Member
From: S/F
Registered: 2004-11-18
Posts: 89

Re: wlk_helpful, a rating plugin

Hey uli, thanks for the reply, I managed to get it working thanks to your suggestion! I couldn’t figure out how to display thumbnail instead of an image but it’s as easy as adding “t” at the end of the file name.

I created a new tag called wlk_helpful_list_image. I’ll copy paste the function here if anybody would like to use it:

function wlk_helpful_list_image($atts)
	{
		global $img_dir;
                global $prefs;
		global $permlink_mode;

		extract(lAtts(array(
			'which'=> (isset($prefs['wlk_helpful_list_image_which']) && $prefs['wlk_helpful_list_image_which']=='bottom')?'bottom':'top',
			'order'=> (isset($prefs['wlk_helpful_list_image_which']) && $prefs['wlk_helpful_list_image_which']=='bottom')?'ASC':'DESC',
			'limit'=> (isset($prefs['wlk_helpful_list_image_limit']) && is_numeric($prefs['wlk_helpful_list_image_limit']))?$prefs['wlk_helpful_list_image_limit']:'5',
			'debug'=> 'false'
		),$atts));

		safe_query('DELETE FROM '.safe_pfx('txp_wlk_helpful_counts').' WHERE textpattern_id NOT IN ( SELECT ID FROM '.safe_pfx('textpattern').' )');

		//Grab the articles with the "top" or "bottom" count count
		$results = safe_query('SELECT txp.Image, txp.ID, txp.Title, txp.Section, txp.Posted, txp.url_title FROM '.safe_pfx('txp_wlk_helpful_counts').' AS helpful LEFT JOIN '.safe_pfx('textpattern').' AS txp ON txp.ID=helpful.textpattern_id ORDER BY count '.$order.' LIMIT 0, '.$limit);

		if(mysql_num_rows($results)>0)
		{
			$results_r = array();
			while($row = mysql_fetch_assoc($results))
			{
				$article_array = $row;
				$article_array['permlink'] = permlinkurl($article_array);
				$results_r[] = $article_array;
			}
			$out = '<ol id="wlkhlpfl'.$which.'">'."\r";
			//create the HTML
			foreach($results_r as $article)
			{
				$out .= "\r\t".'<li><a href="'.$article['permlink'].'"><img src="'.hu.$img_dir.'/'.$article['Image'].'t.jpg" />'.'</a></li>';

			}
			$out .= "\r".'</ol>';
			//Return it
			return $out;
		} else {
			return '';
		}
	}

Last edited by Jaro (2011-08-21 09:00:28)

Offline

#59 2011-08-21 09:05:29

Jaro
Member
From: S/F
Registered: 2004-11-18
Posts: 89

Re: wlk_helpful, a rating plugin

My next PHP challenge is how to get it working with any image extension, not only jpg :)

Offline

#60 2011-08-21 13:19:39

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,303

Re: wlk_helpful, a rating plugin

All that’s needed should be in bot_show_image. I wish you more success than I had :)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

Board footer

Powered by FluxBB