Welcome Guest, Not a member yet? Register   Sign In
trying to use the config class
#1
Shocked 
(This post was last modified: 12-14-2020, 08:48 AM by richb201.)

The lines below are causing an error and i don;'t know why. I get " only variables should be assigned by reference" on line 300 of common.php. I have modified config.php by using 
$config['TYPO'] = 'PHARMA';

Do I need to modify the $config using item to create TYPO in the config class first, before I can use that index? 
I see $this->config->set_item('item_name', 'item_value'); in the docs, but i also see $config['base_url'] =  used in config.php. Should I be using set_item() and if so, where should I put this? 

<?php

  if ($this->config->item('TYPO')=='SOFTWARE'){
    echo '<script type="text/JavaScript"><img src="<?php echo base_url(); ?>assets/themes/default/images/new_blue_logo_sub240x240.png" style="float:left;margin-top:5px;z-index:5" alt="logo"/>
                </script>';
        }
    if ($this->config->item('TYPO')=='PHARMA'){
      echo '<script type="text/JavaScript"><img src="<?php echo base_url(); ?>assets/themes/default/images/output-onlinepngtools (8).png" style="float:left;margin-top:5px;z-index:5" alt="logo"/>
                </script>';
    }

?>
proof that an old dog can learn new tricks
Reply
#2

Why don't you just create your own config file and work with that will save you trouble latter down the road.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 12-14-2020, 02:00 PM by richb201.)

Hey Insite. It seems like overkill to create my own $config file for this one item. I have stuck this in default3.php. default3.php gets called this way in the init().  $this->output->set_template('default3');

          <?php
          $typo=$this->config->item('TYPO');

          if ($typo='SOFTWARE'){                                                            <<<<<here
                echo '<script type="text/JavaScript"><img src="<?php echo base_url(); ? >assets/themes/default/images/new_blue_logo_sub240x240.png" style="float:left;margin-top:5px;z-index:5" alt="logo"/>
                </script>';
              }
          if ($typo='PHARMA'){
                echo '<script type="text/JavaScript"><img src="<?php echo base_url(); ?>assets/themes/default/images/output-onlinepngtools (8).png" style="float:left;margin-top:5px;z-index:5" alt="logo"/>
                </script>';
              };

          ?>
$typo seems to be getting set correctly. But when I walk through it with the debugger, the line marked here causes the debugger to jump to and stop at a line in Loader.php. I have no idea why.
proof that an old dog can learn new tricks
Reply
#4

Your missing an = equals sign here, the way you have it it is assigning the value.

PHP Code:
if ($typo 'SOFTWARE'){

// should be
if ($typo == 'SOFTWARE'){ 

This one is also wrong.

PHP Code:
if ($typo 'PHARMA'){

// should be
if ($typo == 'PHARMA'){ 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

thank you
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB