klox7 VIP
Total posts: 914
10 Feb 2014 09:57

Can it be done? I have a field in Cobalt where I inserted code for adds. The idea is that user can remove this field only if he buys subscription. I just want the field to not be displayed when he buys subscription...because after subscription expires and user don't pay for it I want adds to display again.

Last Modified: 19 May 2014


Sergey
Total posts: 13,748
11 Feb 2014 05:30

What field are you using to display add? textarea?


klox7 VIP
Total posts: 914
12 Feb 2014 01:44

Acctually, no field yet. I'm just trying to figure it out. Because if there is a field user has to edit it do disable adds and I don't want that. I just need when user buys specific subscription this peace of code, or field or... is automatically hidden. After subscription it displays again.

Is there maybe any code for Emerald that can do this and that I can put it in custom template and wrap it around script for adds? Maybe action in Emerald?


Sergey
Total posts: 13,748
12 Feb 2014 01:48

Yes you can use Emerald API

if(!EmeraldApi::hasSubscription(array(1,2,3), null, $item->user_id, false, false))

Where 1,2,3 are IDs of the plans that are require to have to hide ads.


klox7 VIP
Total posts: 914
09 May 2014 08:27

I'm back on this. Upper solution works fine if you insert it for. ex. in record template.

Now I need to do following. For now I display adds in record and client can remove them with subscription and Emerald API.

From now on I would like to move this adds to Joomla module. I would like for client to be able to remove this module, from his records only, if client has subscription.

Possible?


Sergey
Total posts: 13,748
09 May 2014 12:02

klox7 VIP
Total posts: 914
10 May 2014 19:19

Hmm, something is messing with me. Isn't this for something to be visible once user subscribes to it.

I think I need different approach. As said I have in module some piece of code that displays everywhere on site. My users can have their own records. If they want to remove what that code displays, but ONLY from their records, they must buy subscription.


Sergey
Total posts: 13,748
11 May 2014 06:51

Then you use [UNPAID] placeholder. This will show inner part only to those that have no subscription.


    <jdoc:include type="modules" name="ads" style="none" />

This position will be visible only to those who do not have subscriptions 12, 2, 3 and 21


klox7 VIP
Total posts: 914
11 May 2014 19:49

I think it will not do the job right.

Sergey Then you use [UNPAID] placeholder. This will show inner part only to those that have no subscription.

Exactly, but I think it's not what I need. I also need it for specific records of client user.

Let me explain more if I can.

I have two types of users, registered and clients. Clients can post records. In record template I have added custom code with Emerald API from above. Then I created subscription and if client buys this subscription then this code is turned off for his records (so that registered users don't see advertising on their records). This works fine.

Then I wanted to move code outside of Cobalt and put it in Joomla module (just because of space in template) and keep the same functionality.


pepperstreet VIP
Total posts: 3,837
11 May 2014 22:43

klox7 Then I wanted to move code outside of Cobalt and put it in Joomla module (just because of space in template) and keep the same functionality.

So, it is just a matter of the layout? What about CSS and position property to move the Ad to a new location? Maybe "absolute" or "fixed" to the browser window edges/sides.


klox7 VIP
Total posts: 914
12 May 2014 06:45

pepperstreet So, it is just a matter of the layout? What about CSS and position property to move the Ad to a new location? Maybe "absolute" or "fixed" to the browser window edges/sides.

Ha, never thought of it that way. Thanks. Will try it. Maybe with a jQuery clone.


Sergey
Total posts: 13,748
12 May 2014 07:21

Anyway, if you move ads to module, what I have just suggested is perfect. Why not?


Sergey
Total posts: 13,748
12 May 2014 15:27

I see. You what to hide ads on the pages where authors of the articles paid subscriptions. If i paid subscription, then my articles will be shown without ads.

It is like "Remove ads" but it is paied not by the one who access article but the one who publish.

Right?


klox7 VIP
Total posts: 914
12 May 2014 16:22

Yes, exactly :) Thank you. So I tested all 3 variants and this is behaviour. And I want the last one like you said.

PAID subscription DISPLAYS adds ON ALL PAGES for USER WHO BOUGHT subscription and must be LOGGED IN.

UNPAID subscription HIDES adds ON ALL PAGES for USER WHO BOUGHT subscription and must be LOGGED IN.

CODE IN RECORDS TEMPLATE - this is what I want to achieve with module or code in my templates index.php\n\n subscription hides adds ONLY IN USER OWNED RECORDS for all users no matter if they are logged in or not.


Sergey
Total posts: 13,748
12 May 2014 16:49

I have added few parameters to restrict anything for next version. Please read updated documentation for UNPAID

In youe case you can use it like this in template.



klox7 VIP
Total posts: 914
15 May 2014 12:37

Was this added in release today?


Sergey
Total posts: 13,748
16 May 2014 05:29

Yep.


klox7 VIP
Total posts: 914
17 May 2014 14:22

I still can't do it!


It just doesn't show nothing. With subscription off or on.


Sergey
Total posts: 13,748
18 May 2014 07:30

Please confirm it is correct.

This code will show code... text to anyone if author of the article do not have subscription ID - 10. Right? This is what you want?

Also where you placed that code? In template or HTML field?


klox7 VIP
Total posts: 914
18 May 2014 16:20

Sergey This code will show code... text to anyone if author of the article do not have subscription ID - 10. Right? This is what you want?

Yes.

Sergey Also where you placed that code? In template or HTML field?

This is some general script that I have it in my Joomla template index.php file. So it displays everywhere except on home page (it displays also in records). And if somebody doesn't want to display adds in his records he can remove it by buying subscription. Subscription removes adds only from his records.


Sergey
Total posts: 13,748
19 May 2014 05:16

how you then get ID of the user of the article? I mean $this->item or $item is empty there. It is only available in Cobalt template.

If you use it Joomla template, then you have to get article user ID the different way. You have to check URL and if we are in cobalt and view record and id is defined, then you have to get article and extract user ID. If not, do not show code at all.

Replay Topic
Uploading
Click here to upload and insert file from you hard drive: (png, gif, jpg, jpeg, zip, txt, rar)
Powered by Cobalt