- Posts: 24
- Thank you received: 0
Membership content restriction using javascript
- RC Cola
- Topic Author
- Offline
- Junior Member
Less
More
9 years 1 month ago - 9 years 1 month ago #60282
by RC Cola
Membership content restriction using javascript was created by RC Cola
Edit: it's still a little buggy, after working out all the kinks, will update.
Hi all,
I modified the Content - MPrestriction PHP plugin to use Javascript instead of PHP to block content (so content will still be seen by website crawlers, something which should help with SEO). It's not as fast as the PHP implementation (javascript basically does a search & replace on the {mprestriction} ...{/mprestriction}), but seems to do the trick.
Does anyone want a copy of it? It uses the same regular expression as the shipped version, so it should work pretty seamlessly. It's currently in production and seems to be working OK. It uses native Javascript (not JQuery / Mootools, etc.) so it shouldn't conflict with those packages.
Additionally, Tuan if you'd like it to include in the next release, I can send you the code, let me know.
Hi all,
I modified the Content - MPrestriction PHP plugin to use Javascript instead of PHP to block content (so content will still be seen by website crawlers, something which should help with SEO). It's not as fast as the PHP implementation (javascript basically does a search & replace on the {mprestriction} ...{/mprestriction}), but seems to do the trick.
Does anyone want a copy of it? It uses the same regular expression as the shipped version, so it should work pretty seamlessly. It's currently in production and seems to be working OK. It uses native Javascript (not JQuery / Mootools, etc.) so it shouldn't conflict with those packages.
Additionally, Tuan if you'd like it to include in the next release, I can send you the code, let me know.
Last edit: 9 years 1 month ago by RC Cola.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
9 years 1 month ago #60293
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Membership content restriction using javascript
Hi
I don't think I need it for now. Once you have it completed and working properly, please post it in this forum post so that in case someone needs it, they can use it
Regards,
Tuan
I don't think I need it for now. Once you have it completed and working properly, please post it in this forum post so that in case someone needs it, they can use it
Regards,
Tuan
Please Log in or Create an account to join the conversation.
- RC Cola
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
- Thank you received: 0
9 years 1 month ago #60756
by RC Cola
Replied by RC Cola on topic Membership content restriction using javascript
Hi all,
I've emailed Tuan the code for this. For some reason I couldn't post on the forum. No idea what the problem was with that.
I've emailed Tuan the code for this. For some reason I couldn't post on the forum. No idea what the problem was with that.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
9 years 1 month ago #60774
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Membership content restriction using javascript
Thanks. I don't know why you could not post it here (maybe you will need to zip it before posting). I will check my email and post it here. Thanks for sharing
Tuan
Tuan
Please Log in or Create an account to join the conversation.
- RC Cola
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
- Thank you received: 0
9 years 2 weeks ago - 9 years 2 weeks ago #61951
by RC Cola
Replied by RC Cola on topic Membership content restriction using javascript
I updated the code to fix a bug (I think the previous version of the file I sent was the wrong one anyway), and also added a feature to allow for the plugin to completely ignore the membership restriction requirement (it strips out the {mprestriction} tags and returns the text). This is configurable on the plugin config screen.
If you try this, please share your feedback. Thanks.
If you try this, please share your feedback. Thanks.
Last edit: 9 years 2 weeks ago by RC Cola.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
9 years 1 week ago #61999
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Membership content restriction using javascript
I think we can have simpler implementation. We can check in PHP code to see whether the current user-agent is bot and then we will still show the restricted content. I think that would be simpler than working with javascript
Tuan
Tuan
Please Log in or Create an account to join the conversation.
- RC Cola
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
- Thank you received: 0
9 years 1 week ago #62001
by RC Cola
Replied by RC Cola on topic Membership content restriction using javascript
That's a good idea.
Have you any experience with JBrowser->isRobot()? That looks like it would do the trick, but curious how well it works.
Thanks Tuan!
Have you any experience with JBrowser->isRobot()? That looks like it would do the trick, but curious how well it works.
Thanks Tuan!
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
9 years 1 week ago - 9 years 1 week ago #62045
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Membership content restriction using javascript
Hi
Based on my experience, you can use this code:
Regards,
Tuan
Based on my experience, you can use this code:
Code:
$app = JFactory::getApplication();
if ($app->client->robot)
{
}
Regards,
Tuan
Last edit: 9 years 1 week ago by Tuan Pham Ngoc.
Please Log in or Create an account to join the conversation.
- RC Cola
- Topic Author
- Offline
- Junior Member
Less
More
- Posts: 24
- Thank you received: 0
9 years 1 week ago #62157
by RC Cola
Replied by RC Cola on topic Membership content restriction using javascript
Hi Tuan,
Thanks for that, I'll take a look.
If anyone else interested in this? If you're looking at this thread, do a quick reply & say something if you'd like to see this feature in this plugin. If there's enough interest, I'll make the change & re-upload
Thanks all
Thanks for that, I'll take a look.
If anyone else interested in this? If you're looking at this thread, do a quick reply & say something if you'd like to see this feature in this plugin. If there's enough interest, I'll make the change & re-upload
Thanks all
Please Log in or Create an account to join the conversation.
Support
Documentation
Information
Copyright © 2024 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.