Plugin Development Question Help

Post Reply
bbyrdhouse
Ssr. Bludit
Posts: 15
Joined: Sun Mar 08, 2020 1:36 am

Sat Mar 14, 2020 12:50 am

Hi,

I am wanting to build a plugin to accompany my theme that will let the end user select what color scheme they want their site to use.
I thought the best way to do this would be in a plugin where they could select from select/options like below:

Code: Select all

$html .= '<div>';
		$html .= '<select name="colorScheme">';
		$html .= '<option value="default.css">Red</option>';
		$html .= '<option value="light.css">Light</option>';
		$html .= '<option value="dark.css">Dark</option>';
		$html .= '</select>';
		$html .= '</div>';

		return $html;
	}

	public function siteHead()
	{
		global $L;
		global $color;

		// HTML for head
		
		$html  =  '<link rel="stylesheet" type="text/css" href=".'$this->getValue("colorScheme").'" />'
		
		return $html;
	}
}
However, this does not work ... as a matter of fact, it sort of breaks the whole site. So I know that I have an error(s) in my code.

So, I want to know if someone has a similar plugin whith numerous options that the user can select that I can take a look at ... or can someone spot what I am doing wrong in my code?
User avatar
stokesman
Jr. Bludit
Posts: 3
Joined: Thu Mar 19, 2020 10:02 pm

Fri Mar 20, 2020 2:29 am

Code: Select all

$html  =  '<link rel="stylesheet" type="text/css" href=".'$this->getValue("colorScheme").'" />'
The dot after href=" has to switch places with the single quote that follows it (make it href="'.) and then put a semi-colon at the end of the line. That might get it going if you don't have other errors elsewhere.

Also, you might like to know about and utilize the includeCSS method of plugins:

Code: Select all

$html = $this->includeCSS( $this->getValue('colorScheme') );
Post Reply