I am creating an accessory that will access a table that I have created to update the value of a field. I have it set up so that if the value is 1 the page will be rendered and if the value is 0 the page will not be rendered. I have gotten everything down except getting the value to change via the access class.
What I currently have is a link that will execute an onclick to call another function within the accessory that evaluates the value of the field and then decides to change the value based on that.
Here is a sample of the code:
/**
* The Blog Switch Accessory
*
* @package ' '
* @author Jeremy Herb
*/
class Blog_switch_acc {
var $name = 'Blog Switch';
var $id = 'blog_acc';
var $version = '1.0';
var $description = 'This accessory will allow you to turn your blog page on and off';
var $sections = array();
/**
* Constructor
*/
public function Blog_switch_acc()
{
$this->EE =& get_instance();
}
//onclick execute function to change value
public function set_sections()
{
$this->sections["On/Off Switch"] = "
<a href='#' onclick='switcher()'>On/Off</a>
<p>To turn the blog on or off click the button above</p>";
}
public function switcher()
{
$query = $this->EE->db->query("SELECT blog_on_off FROM db_options");
$set_to = $query == false;
$this->EE->db->query("UPDATE db_options SET blog_on_off = $set_to");
}
}
/* End of file acc.blog_switch.php */
/*Location:./system/expressionengine/third_party/blog_switch/acc.blog_switch.php*/
My apologies if it looks bad on the forum, this is my first post here.
Thanks, Jeremy Herb