I have a subscription link on a page that the logged in users can use.
Toggling the link on the page is no issue, as I can do a .post and echo out what the PHP returns
if ($subscription == true) {
echo 'Subscribed';
} else {
echo 'Click to subscribe';
}
However, what bugs me is that I have to write that same piece of code in my template file. I could however make an ajax call for that immediately as the page loads.
What is the best way of doing this?
Okay I decided to fix it using PHP. Now when you hit the page it calls for :
http://url/module/controller/check/id/$id/object/$object_name
and ajax’d it into my div. Then if its clicked it goes to and puts the return value in the html
http://url/module/controller/toggle/id/$id/object/$object_name
Class:
}
and the view code is: