beginner question: fuel_var on homepage

edited November 2011 in Installation
Hello,

I created a site variable in the admin area for my twitter handle which is called "twitter". I'm trying to call it on my homepage in the footer block using <?=fuel_var('twitter')?> but nothing happens. Am I missing something?

Comments

  • edited 7:31AM
    How is the page being rendered... meaning is it a page created in the admin, a static view file (no controller), or a controller/view?
  • edited 7:31AM
    Controller / View. I'm bringing over a old CI site. Below is my controller.

    --

    <?php
    class Home extends CI_Controller{

    function __construct(){
    parent::__construct();
    }

    function Home()
    {
    parent::Controller();
    }

    public function index()
    {
    $vars = array('' => '');

    $this->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'home'));
    $this->fuel_page->add_variables($vars);
    $this->fuel_page->render();
    }
    }

    ?>
  • edited 7:31AM
    Hmm... I tested this locally and am not able to replicate the problem (was able to see the merged in value). What happens if you just use:
    <?=$twitter?>
  • edited 7:31AM
    No luck...I get the undefined variable error.

    In my Site Variables, I have the variable called 'twitter' which is active and no scope.

    BUT when I add "$vars['twitter'] = '@me';" to _variables/global.php, it works.

    Could it not be looking at the DB for this information? Is there a setting where I can change where Fuel looks?
  • edited 7:31AM
    What do you have the $config['fuel_mode'] set to in you MY_fuel.php file?
  • edited 7:31AM
    Great! Set it to auto since my page content will most likely be from view files but I want to manage my global vars in the admin area.

    Love the CMS, thanks for all your help!
  • edited 7:31AM
    So that did the trick?
  • edited 7:31AM
    yes, thanks.
  • edited 7:31AM
    I am trying to do this same thing and am experiencing the same problem this thread originally voiced in that I am not seeing the value displayed on the view using the fuel_var function. I have my fuel_mode set to auto, but I have not added anything additional to the _variables/global.php file as mentioned above by ok1ha.

    What I want to do is quite simple. I have a Site Variable with a name of "Annual Gift Certificate Price" stored in Fuel with a value of 60. Plain and simple, it just stores a number.

    In my view file I have this:

    <?=fuel_var('Annual Gift Certificate Price')?>

    I'm using the controller method to render the view file, so this is not a fuel page I am trying to load. Also, if it helps, I am doing all of this from a custom module I created called "store".

    Thanks,
    Erik
  • edited 7:31AM
    Try changing the site variable name to something like 'annual_gift_certificate_price' without any spaces. Also, you should be able to just do a regular merge without fuel_var like so to just test the variables existence in the view:
    <?=$annual_gift_certificate_price?>
Sign In or Register to comment.