Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

theme control panel

Featured Replies

hey guys,

 

i want to apologise in advance for being very broad, with little understanding about php its a bit confusing as to what to search!

 

i have spent alot of my time, working on personal themes and variouis other things, along the way ive created some really nice magento themes! the problem is that i see 90% of the popular themes have some sort of control panel for users to easily change colours / styles etc.

 

my question is, how is this being done?

 

obviouslly on the actual page, all that is being loaded is 'calling' the php variable / function but thats it,

 

How is php storing the different options & where? i understand the information is stored in a variable, but where? the database?

How do you assign an options and then assign them to your variable?

 

sorry again, my understanding of php is grim, javascript i have down!

 

Thanks guys

Hey there

 

My ore prerequisite is I only have experience with Wordpress.

 

With Wordpress try looking at the theme customisation Api - with that you can get all of the colours etc that you want in the settings section.

 

With little php experience though you may find it more difficult.

 

Good luck!

  • Author

hi ben,

 

i learn really fast, ive been at this 10 months and as many of you will tell you here im lightyears ahead of where i should be.. Throw me a bone and let me know the basics and ill soon know what to search for and piece it together myself :)

 

Best way to learn to get to my hands dirty

 

Andy

 

EDIT: highly experianced in jquery + js so i got the basics of how programming works, its just a case of figuring it out in php, as its more about arrays and such

Edited by webcanvasdesign

I've not done this before and I mostly handcode - you can store the variables/options in an array or a database. Depending on the option entered, you could pull in a different css file. Using an array would be faster.

 

Set up a configurations file, which every page includes. In the configurations file you can create a function that will define the array of options and actions and return to the calling page which action (or stylesheet) to pull in. When you call the function be sure to do so with a variable assignment statement to have access to the returned variable. Let me know if you need an example.

  • Author

hey g,

 

sorry for the long reply, been swamped. If you could provide a short example that would be amazing! i find it hard to learn by reading, i have to do :p and figure out some issues in between

 

thanks mate

Ok there are several steps and I've simplified the process. I've used sessions to allow the chosen stylesheet to be accessed by all the pages. Knowing javascript you'll be familiar with sessions. Look in the php manual for the syntax - the main thing is to ensure you start the session with session_start() as the absolute first thing on pages that use the $_SESSION variable. If not, you will get an error.

 

1. In your configuration or functions file define the function

function set_stylesheet($colour) {
	$styles_file=array('blue'=>'blueStyles.css', 'red'=>'redStyles.css', 'green'=>'greenStyles.css');
	return $styles_file[$colour];
}

2. In your html page, you can have a mini form to allow the user to select the colour. The form action will call the set_stylesheet function and store it in a session. e.g.

<?php
session_start()
?>

<!DOCTYPE html>
<head>
...
</head>
<body>
$colours = array('blue', 'red', 'green');
if (isset($_POST['colour']) && in_array($_POST['colour'],$colours)) {
    $_SESSION['stylesheet'] = set_stylesheet($_POST['colour']);
}
?>


<form action="" method="post">
<select name="colour">
<?php
foreach ($colours as $colour) {
	echo '<option value="' . $colour . '">' . $colour . '</option>';
}
?>
<input type="submit" value="Choose colour" />
</select>
</form>

3. The head section of your pages will access the session variable to pull in the appropriate stylesheet.

<?php
session_start()
?>

<!DOCTYPE html>
...
<head>
if ($_SESSION['stylesheet']) {
     echo '<link href="' . $_SESSION['stylesheet'] . '" rel="stylesheet" type="text/css"/>';
}
else {
     echo '<link href="default.css" rel="stylesheet" type="text/css"/>';
}
?>
</head>

 

I have limited experience working with cms sites so you will need to alter the above to suit your cms. And for themes you might want to store the value in a configurations table rather than a session. Hope this helps.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.