Please forgive me if the answer to my query is obvious or simple, but I am not at all familiar with PHP.
I am trying to create a simple plugin to store a bunch of variables such as phone number, fax number, email address etc.. and then pull those lines into a theme's PHP.
This is the code in plugin.php :
Code: Select all
<?php
class contactDetails extends Plugin {
public function init()
{
$this->dbFields = array(
'contactdetailstitle'=>'Company Name',
'contactdetailsline1'=>'081 123 4567',
);
// make $contactDetails object available in theme
global $contactDetails;
$contactDetails = $this;
}
public function form()
{
global $L;
$html = '<div class="alert alert-primary" role="alert">';
$html .= $this->description();
$html .= '</div>';
$html .= '<label>Contact Details Title:</label>';
$html .= '<input name="contactdetailstitle" id="jscontactdetailstitle" type="text" value="'.$this->getValue('contactdetailstitle').'">';
$html .= '<div>';
$html .= '<label>Contact Details Line 1:</label>';
$html .= '<input name="contactdetailsline1" id="jscontactdetailsline1" type="text" value="'.$this->getValue('contactdetailsline1').'">';
$html .= '</div>';
return $html;
}
public function contactdetailstitle()
{
return $this->getValue('contactdetailstitle');
}
public function contactdetailsline1()
{
return $this->getValue('jscontactdetailsline1');
}
}
?>
and here is the code that I am using in my theme's PHP:
Code: Select all
<h2 class="footer-colour"><?php echo Theme::plugins('contactdetailstitle');?></h2>
<ul>
<li>
<span class="menu-item" style="color: #b9b8b7";><?php echo Theme::plugins('contactdetailsline1');?></span>
</li>
</ul>
I would be very grateful if somebody could have a look at this code and perhaps enlighten me where the error lies?
Many thanks,
Bruce.