Site variables empty

I set up some site variables and put them on a view like this: <?php echo fuel_var('copyright', "2011"); ?>
They show up correct on the pages, but when in inline edit mode, the edit popup shows an empty field. When I submit some text into the little form, nothing gets saved either.
Page variables are working fine, only site variables don't work. I saw that site variable fuel markers don't have an id:

However I have no clue how to fix this.

Anyway to make them work?
Thanks in advance.

Comments

  • edited June 2011
    For site variables, you do need an ID for them to work and you should be able to use the following if you have already grabbed the value from the database as a variable $pagevar:<?=fuel_edit($pagevar->id, 'Edit page variable: '.$pagevar->name, 'sitevariables')?>
    Otherwise, you can use the following assuming that "1" is the id value of copyright in the database:
    <?=fuel_edit(1, 'Edit page copyright', 'sitevariables')?>
  • edited June 2011
    Ah thanks!

    I tried to make it possible to reference site variables with their names instead of ids. Here's what I came up with: (create fuel/modules/fuel/controllers/sitevariables.php)
    <?php require_once('module.php'); class Sitevariables extends Module { function inline_edit($var) { if (is_ajax()) { // try to get the id, if $var is a name $this->load->module_model(FUEL_FOLDER, 'sitevariables_model'); $site_var = $this->sitevariables_model->find_one(array('name' => $var)); // set $id to $var if we didn't find a site variable $id = empty($site_var) ? $var : $site_var->id; parent::inline_edit($id); } } }

    It's backwards compatible with id's
    So this works:
    <?php echo fuel_var('some_sitevar', 'default', 'sitevariables'); ?>
    as well as this:
    <?php echo fuel_var(1, 'default', 'sitevariables'); ?>
    I don't know if you can/want to use this, but maybe it helps others ;)
  • edited 6:35PM
    This is great... I'll look into adding this.
  • edited 6:35PM
    I've added this to the repo. Thanks for the contribution.
Sign In or Register to comment.