News:

Support for jDownloads 3 has been ended
Since 17 August 2023 Joomla.org has discontinued support for Joomla 3.x. Therefore, we will no longer offer official support for our Joomla 3 jDownloads version 3.9.x from January 2024.
Please update your website to the latest Joomla version (Joomla 4 or Joomla 5) as soon as possible. Afterwards, please update jDownloads to the latest published version. The longer you delay, the more difficult the upgrade process for your website is likely to be.

Main Menu
Support-Forum

0 - Using $this when not in object context

Started by cariss, 26.02.2019 17:56:08

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cariss

Hi there,

I'm suddenly getting an error on my site using latest joomla 3.9.3 and latest jdownloads 3.2.63.

Jdownloads seems to be working fine, I've created a test menu item that links to list all downloads and it shows all the files fine; https://www.ekla.org.uk/test3

However, I've got a menu item with menu type "jDownloads » List my Downloads » List my Downloads" and I get the error "0 - Using $this when not in object context" on clicking on that link; https://www.ekla.org.uk/resources

I've tried setting the site template to protostar and get the same error when using that as the default template. I also tried deleting the latest file that was added when the error was noticed thinking maybe there was an issue with the file but removing it hasn't made any difference either.

Does anyone have any ideas for what else I can try?
thanks
  •  

ColinM

Hi
Not sure I understand!
You created a j Downloads menu link of Menu Item Type "List All Downloads" and I assume you gave it a title of "test3".
This creates a menu item with a link like <a href="/test3">list all downloads</a>  where test3 is the alias not the title.  If I then make this into the full reference  https://www.mysite.com/test3 then it works OK.
The key is that it must be the alias.  Maybe the alias for 'resources' is not resources or that resources is a sub category of say a top level category called Kent Info.  In which case the link would be something like https://www.mysite.com/kent-info/resources
Colin
Colin M
  •  

cariss

Hi, thanks for replying.

Apologies for the confusion.

The resources page (https://www.ekla.org.uk/resources) has always worked fine in the past, we have just suddenly noticed that it is now not working and showing the error; 0 - Using $this when not in object context

The resources page is a "List my Downloads" type of page, so when the user is logged in it only shows the files assigned to them.

I created the test3 page just to check that jdownloads on the whole still works, which it appears to.
  •  

ColinM

Hi
Then this looks like a possible Permissions or view Access problem that has arrisen in latest Joomla!Normally a menu link to a 'registered' only area would be set as a 'registered' view access.In trying to simulate the situation Joomla! 3.9.3 correctly directed me to the login page but It was not a list my downloads type page.Will try later.
Colin
Colin M
  •  

cariss

#4
How I've got it setup is the menu link and access to it is public, and then the type is just a jdownloads my downloads type;



Then I've got a few different user accounts setup that are just in the registered user group, and then I add files to jdownloads and to assign them to the different users I change the "created by" field to one of those users, that way when they click on the resources link they just see the files that are theirs.
  •  

ColinM

#5
Hi
I have created a menu item type List My Downloads with a Title Resources and alias resources.  Also of course I set up a registered user and set that user as the creator of a couple of Downloads that were Registered Access.This has a link like https://www.mysite.com/resourcesThen I logged on - the menu item and the separate direct link on its own page  -  both worked.Next I logged the user out and cleared all the browser cache.  The result was an error message, see pic attached.  As you will see it has the error message "0 - Using $this when not in object context"  but also has the problem identified as possibly being "you have no access to this page"
So the user needs to be logged in before accessing that resource! To double check I set the permissions to Download as allowed and view access to Public. And it still failed.
Then of course I realised that Joomla!/jD  had no user so it could not find and gave an error message. Sometimes a user may log out but the cache is still intact and maybe previously Joomla! 'remembered' the previous logged in front end user.
Colin

[gelöscht durch Administrator]
Colin M
  •  

Arno

QuoteNormally a menu link to a 'registered' only area would be set as a 'registered' view access
Exactly! Every other use is senseless.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

cariss

Many thanks for checking it out. Can confirm I replaced the resources link with just a link to a login page, and then setup a redirect on login to go to the users "my downloads".

It just worked before that when people ended up on the my downloads page and weren't already logged in it prompted them to login, guess something changed at joomla and now they have to be logged in first.
  •