sitemap  |  contact

Sakic.Net Forum
23 November 2008, 19:14 *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
News: Email Directory goes free: http://www.sakic.net/products/free_products/
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: New problem with PHP plugin  (Read 2524 times)
Arnaud
Newbie
*
Posts: 43


View Profile
« on: 02 April 2008, 11:41 »

Hi Emir !

I have a problem with a PHP Plugin i'm trying to develop (latest news). I can't find what's wrong with my code, so your help would be very appreciate !

I pass a variable in my url to filter on my news categories. Here is my URL with my variable 'cat' :

Quote
index.php?option=com_content&task=section&id=1&Itemid=2&cat=13

Now, here is my PHP code to extract my variable content :

Code:
$url = $_SERVER['QUERY_STRING'];
parse_str($url, $output);
$cat = $output['cat'];

And now my SQL code :

Code:
$query = "SELECT count(id) FROM #__content WHERE sectionid = '1' AND catid = $cat AND state = '1'";

When i execute my module, i have no result (Loading...). If i set the debug mode on, i can see my variable is passed :

Code:
SELECT count(id) FROM jos_content WHERE sectionid = '1' AND catid = 13 AND state = '1'

But, if i manually set "$cat = 13" in my php code, i have my module result !

I don't know why it's not working... Is there a problem with my PHP code or with the API ?

Thank you for your help, Emir !

Arnaud
Logged
Arnaud
Newbie
*
Posts: 43


View Profile
« Reply #1 on: 02 April 2008, 12:25 »

I've activated debug mode in the plugin and I can see the content.

So the problem come from the API !

Emir ! Help, please ! Cheesy
Logged
Saka
Administrator
Hero Member
*****
Posts: 1,294


View Profile WWW
« Reply #2 on: 02 April 2008, 17:26 »

Please attach the plugin so I can test.
Logged

Arnaud
Newbie
*
Posts: 43


View Profile
« Reply #3 on: 02 April 2008, 18:21 »

Check MP, Emir Wink
Logged
Arnaud
Newbie
*
Posts: 43


View Profile
« Reply #4 on: 05 April 2008, 15:33 »

Hi Emir !

Do you have information about my plugin issue ?

Arnaud
Logged
Saka
Administrator
Hero Member
*****
Posts: 1,294


View Profile WWW
« Reply #5 on: 05 April 2008, 16:29 »

Not yet, I've been busy. Will check that soon.
Logged

Arnaud
Newbie
*
Posts: 43


View Profile
« Reply #6 on: 11 April 2008, 08:13 »

Here is what I have in my Firebug Console. Hope this can help !
Logged
Arnaud
Newbie
*
Posts: 43


View Profile
« Reply #7 on: 27 April 2008, 08:13 »

1 month later, Emir, and i'm still waiting for your support !!  Angry
Logged
Saka
Administrator
Hero Member
*****
Posts: 1,294


View Profile WWW
« Reply #8 on: 27 April 2008, 16:21 »

Hi Arnaud,

Unfortunatelly something like this is not supported. What you are trying to do is to modify the behavior of the module by dynamically filtering the results. This is not supported by the module. Also, you can't make a plugin to use the query string like you wanted because of the way the AJAX works. The query string of the site request is not the same as the query string passed when asyncronously requesting the module content. If you use Firebug you will be able to see that. So you can't pass information to the module with query string of the page.

What you can do is to filter the results by variables that are sent by module's API to the plugin's get_content() function, for example by $option or $selectedid. For example, you could look up the catid for the id of the article that's been selected ($selectedid) and then display only the articles that belong to its category.

It took a while until I understood what you are trying to do so it's good that you did setup a test page for me.
« Last Edit: 27 April 2008, 16:31 by Saka » Logged

Arnaud
Newbie
*
Posts: 43


View Profile
« Reply #9 on: 27 April 2008, 18:22 »

Hi Emir !

Thanks for your reply. However, when debug mode is activated the content is well filtered and I can see it in $content variable. So, data selection is well done ! The problem is when I want to show it... If $content contain the data why the API is not able to show it ??
Logged
Saka
Administrator
Hero Member
*****
Posts: 1,294


View Profile WWW
« Reply #10 on: 27 April 2008, 22:59 »

Which debug mode?
Data selection is impossible with your $cat variable because it's not passed in the query string. Only if you hardcoded it you might have filtered the data.
Logged

Arnaud
Newbie
*
Posts: 43


View Profile
« Reply #11 on: 28 April 2008, 08:11 »

Debug mode :

Code:
echo "<pre> content : "; var_export($content);

Uncomment this line in my PHP plugin in place of :

Code:
return $content;

For your information Emir, my variable is well passed in the query string cause, as I previously said, in debug mode i can see my filtered content !
Logged
Saka
Administrator
Hero Member
*****
Posts: 1,294


View Profile WWW
« Reply #12 on: 28 April 2008, 10:59 »

Yes but you get the filtered content only the first time when the page is loaded syncronously because the class is initialized then. If you click on the module's refresh icon you will see that your echoed content is not reloaded. So it's not possible to retrieve it asyncronously.

I hope this makes sense, otherwise you will just have to accept it's not possible to do and that it's not supported. As I mentioned before, you can use $selectedid to filter the results, but you can't use variables from the query string.
« Last Edit: 28 April 2008, 11:01 by Saka » Logged

Arnaud
Newbie
*
Posts: 43


View Profile
« Reply #13 on: 29 April 2008, 12:17 »

Arfff  Cry  Cry Cry

So I have to build 1 plugin per category. And if i wanted to offer a filter by author... same way Sad

One last question, please. I'd like to change the refresh picture. How can i do this ?
Logged
Saka
Administrator
Hero Member
*****
Posts: 1,294


View Profile WWW
« Reply #14 on: 29 April 2008, 13:55 »

Currently it can't be changed, it's hardcoded in the module. You don't like it? I could put it externally in the next version maybe.
Logged

Pages: [1]
  Print  
 
Jump to: