Set  page in theme settings? I've created a settings page for my theme, and I'd like to be able to set the frontpage from there, but I don't know how I can change the frontpage in code?

This is the setting:

$node_type = "page";
$result = db_query(
    'SELECT n.nid, n.title FROM {node} n WHERE n.type = :type',
    array(':type' =&gt; $node_type)
);
$options = array();
foreach ($result as $record) {
    $options[$record-&gt;nid] = $record-&gt;title;
}

$form['static_nodes']['front_page_id'] = array(
    '#type'        =&gt; 'select',
    '#title'       =&gt; t('Frontpage'),
    '#options'     =&gt; $options,
    '#description' =&gt; t('Set the page used as the frontpage.'),
    '#default_value' =&gt; theme_get_setting('front_page_id'),
);
Solution:  

function billetsalget_form_system_theme_settings_alter(&amp;$form, &amp;$form_state)
{
    /**
     * The group fieldset
     */
    $form['static_nodes'] = array(
        '#type'          =&gt; 'fieldset',
        '#title'         =&gt; t('Static Pages'),
        '#weight'        =&gt; -2,
    );

    /**
     * Get pages from db as options
     */
    $node_type = "page";
    $result = db_query(
        'SELECT n.nid, n.title FROM {node} n WHERE n.type = :type',
        array(':type' =&gt; $node_type)
    );
    $options = array();
    foreach ($result as $record) {
        $options[$record-&gt;nid] = $record-&gt;title;
    }

    /**
     * Select dropdown for Frontpage
     */
    $form['static_nodes']['front_page_id'] = array(
        '#type'        =&gt; 'select',
        '#title'       =&gt; t('Frontpage'),
        '#options'     =&gt; $options,
        '#description' =&gt; t('Set the page used as the frontpage.'),
        '#default_value' =&gt; theme_get_setting('front_page_id'),
    );

    /**
     * Run function when form is submittet
     */
    $form['#submit'][] = 'billetsalget_form_system_theme_settings_submit';
}

function billetsalget_form_system_theme_settings_submit(&amp;$form, &amp;$form_state)
{
    /**
     * Set frontpage to 'node/' + node_id selected in the form
     */
    variable_set('site_frontpage', 'node/' . $form_state['values']['front_page_id']);
}